"20240512111706"

This commit is contained in:
itsscb 2024-05-12 23:50:07 +02:00
parent 5c4533e893
commit 63da041bf5
7 changed files with 335 additions and 224 deletions

View File

@ -14,10 +14,6 @@
url = "github:Mic92/sops-nix"; url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
# hyprlock = {
# url = "github:hyprwm/hyprlock";
# inputs.hyprland.follows = "hyprland";
# };
home-manager = { home-manager = {
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";
@ -25,10 +21,21 @@
}; };
}; };
outputs = { self, nixpkgs, ... }@inputs: { outputs = {
self,
nixpkgs,
...
} @ inputs: {
inherit self;
nixosConfigurations.default = nixpkgs.lib.nixosSystem { nixosConfigurations.default = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {inherit inputs;}; specialArgs = {inherit inputs;};
modules = [ modules = [
({pkgs, ...}: {
# Let 'nixos-version --json' know about the Git revision
# of this flake.
system.configurationRevision = self.lastModifiedDate;
})
./hosts/default/configuration.nix ./hosts/default/configuration.nix
inputs.home-manager.nixosModules.default inputs.home-manager.nixosModules.default
]; ];

View File

@ -1,16 +1,20 @@
# Edit this configuration file to define what should be installed on # Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page # your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help). # and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, inputs, ... }:
{ {
imports = config,
[ # Include the results of the hardware scan. pkgs,
./hardware-configuration.nix inputs,
inputs.home-manager.nixosModules.default ...
inputs.sops-nix.nixosModules.sops }: {
]; imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
inputs.home-manager.nixosModules.default
# Secrets Manager
inputs.sops-nix.nixosModules.sops
];
sops.validateSopsFiles = false; sops.validateSopsFiles = false;
sops.defaultSopsFile = "/etc/nixos/secrets/secrets.yaml"; sops.defaultSopsFile = "/etc/nixos/secrets/secrets.yaml";
@ -32,7 +36,7 @@
boot.initrd.luks.devices."luks-ddb552e7-c477-4d71-899b-9224d6782b9f".device = "/dev/disk/by-uuid/ddb552e7-c477-4d71-899b-9224d6782b9f"; boot.initrd.luks.devices."luks-ddb552e7-c477-4d71-899b-9224d6782b9f".device = "/dev/disk/by-uuid/ddb552e7-c477-4d71-899b-9224d6782b9f";
networking.hostName = "scbnb"; # Define your hostname. networking.hostName = "scbnb"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
nix.settings.experimental-features = [ "nix-command" "flakes"]; nix.settings.experimental-features = ["nix-command" "flakes"];
# Enable networking # Enable networking
networking.networkmanager.enable = true; networking.networkmanager.enable = true;
@ -63,7 +67,7 @@
services.xserver.desktopManager.gnome.enable = true; services.xserver.desktopManager.gnome.enable = true;
# Configure keymap in X11 # Configure keymap in X11
services.xserver.xkb= { services.xserver.xkb = {
layout = "us"; layout = "us";
variant = ""; variant = "";
}; };
@ -81,7 +85,6 @@
alsa.support32Bit = true; alsa.support32Bit = true;
pulse.enable = true; pulse.enable = true;
jack.enable = true; jack.enable = true;
}; };
users.groups.fsc = { users.groups.fsc = {
@ -93,37 +96,35 @@
isNormalUser = true; isNormalUser = true;
uid = 1000; uid = 1000;
description = "itsscb"; description = "itsscb";
extraGroups = [ "networkmanager" "wheel" "fsc"]; extraGroups = ["networkmanager" "wheel" "fsc"];
packages = with pkgs; [ packages = with pkgs; [
]; ];
}; };
users.users."k.sc"= { users.users."k.sc" = {
isNormalUser = true; isNormalUser = true;
uid = 1001; uid = 1001;
description = "k.sc"; description = "k.sc";
extraGroups = [ "networkmanager" "fsc"]; extraGroups = ["networkmanager" "fsc"];
packages = with pkgs; [ packages = with pkgs; [
]; ];
}; };
fonts.packages = with pkgs; [ fonts.packages = with pkgs; [
nerdfonts nerdfonts
]; ];
programs = { programs = {
steam = { steam = {
enable = true; enable = true;
}; };
hyprland = { hyprland = {
enable = true; enable = true;
xwayland.enable = true; xwayland.enable = true;
}; };
chromium = { chromium = {
enable=true; enable = true;
homepageLocation = "https://start.duckduckgo.com"; homepageLocation = "https://start.duckduckgo.com";
extraOpts = { extraOpts = {
syncDisabled = true; syncDisabled = true;
@ -131,7 +132,7 @@
PasswordManagerEnabled = false; PasswordManagerEnabled = false;
SpellcheckEnabled = false; SpellcheckEnabled = false;
}; };
defaultSearchProviderEnabled= true; defaultSearchProviderEnabled = true;
defaultSearchProviderSearchURL = "https://start.duckduckgo.com/?q={searchTerms}"; defaultSearchProviderSearchURL = "https://start.duckduckgo.com/?q={searchTerms}";
}; };
}; };
@ -141,12 +142,10 @@
WLR_NO_HARDWARE_CURSORS = "1"; WLR_NO_HARDWARE_CURSORS = "1";
NIXOS_OZONE_WL = "1"; NIXOS_OZONE_WL = "1";
}; };
variables = { variables = {
EDITOR = "hx"; EDITOR = "hx";
}; };
}; };
hardware = { hardware = {
@ -154,85 +153,141 @@
nvidia.modesetting.enable = true; nvidia.modesetting.enable = true;
}; };
home-manager = { home-manager = {
extraSpecialArgs = { inherit inputs; }; extraSpecialArgs = {inherit inputs;};
backupFileExtension = "backup"; backupFileExtension = "backup";
users = { users = {
"itsscb" = import ./home.nix; # ( config.sops.secrets."git"); "itsscb" = import ./home.nix; # ( config.sops.secrets."git");
"root" = { "root" = {
home.stateVersion = "23.11"; home.stateVersion = "23.11";
home.file.".config/helix".source = ../../dotfiles/helix; home.file.".config/helix".source = ../../dotfiles/helix;
programs.bash = {
enable = true;
shellAliases = {
ls = "eza -la --git";
grep = "rg";
cat = "bat";
};
};
};
}; };
}; };
};
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
xdg.portal.enable = true; xdg.portal.enable = true;
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
age # nix specific
## Secrets Manager
sops sops
curl
## nix formatter
alejandra
# Encryption
age
# Hyprland / Window Manager
xdg-desktop-portal-gtk
xdg-desktop-portal-hyprland
## App Starter
rofi-wayland
## Network Settings
networkmanagerapplet
# Audio Settings
pavucontrol
## Bluetooth Settings
blueman
## Lockscreen
hyprlock
## Top Bar
waybar waybar
(waybar.overrideAttrs (oldAttrs: { (
waybar.overrideAttrs (oldAttrs: {
mesonFlags = oldAttrs.mesonFlags ++ ["-Dexperimental=true"]; mesonFlags = oldAttrs.mesonFlags ++ ["-Dexperimental=true"];
}) })
) )
## ???
dunst dunst
## Notification Daemone (?)
libnotify libnotify
swww ## File Manager
broot
jq
poppler
fzf
dolphin dolphin
breeze-icons breeze-icons
# cifs-utils
networkmanagerapplet
alacritty
xdg-desktop-portal-gtk
xdg-desktop-portal-hyprland
rofi-wayland
pavucontrol
blueman
hyprlock
## ???
swww
# Clipboard Manager
xclip
# Image Manipulation
inkscape inkscape
gimp gimp
ffmpeg
xclip
eza
bat
ripgrep
gitFull
rustup
helix
# vim
thunderbird
# Video
ffmpeg
vlc vlc
# Music
spotify spotify
# Terminal
alacritty
## 'ls' replacement
eza
## 'cat' replacement
bat
## 'grep' replacement
ripgrep
## 'find' replacement
fd
## Default Tools
curl
gitFull # git
broot # file manager
jq # json tool
poppler # ???
fzf # ???
# Editor
helix
# Mail Client
thunderbird
]; ];
services.xserver.excludePackages = (with pkgs; [ services.xserver.excludePackages =
nano (with pkgs; [
xterm nano
]) ++ ( with pkgs.gnome; [ xterm
cheese ])
gnome-music ++ (with pkgs.gnome; [
epiphany cheese
geary gnome-music
totem epiphany
tali geary
iagno totem
hitori tali
atomix iagno
]); hitori
atomix
]);
fileSystems = { fileSystems = {
"/mnt/home" = { "/mnt/home" = {
@ -256,7 +311,6 @@ home-manager = {
fsType = "cifs"; fsType = "cifs";
options = let options = let
automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user"; automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user";
in ["${automount_opts},credentials=${config.sops.secrets."nas".path},uid=1000,gid=1010"]; in ["${automount_opts},credentials=${config.sops.secrets."nas".path},uid=1000,gid=1010"];
}; };
"/mnt/shared" = { "/mnt/shared" = {
@ -264,17 +318,15 @@ home-manager = {
fsType = "cifs"; fsType = "cifs";
options = let options = let
automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user"; automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user";
in ["${automount_opts},credentials=${config.sops.secrets."nas".path},uid=1000,gid=1010"]; in ["${automount_opts},credentials=${config.sops.secrets."nas".path},uid=1000,gid=1010"];
}; };
}; };
programs.nix-ld.enable = true; programs.nix-ld.enable = true;
programs.nix-ld.libraries = with pkgs; [ programs.nix-ld.libraries = with pkgs; [
# Add any missing dynamic libraries for unpackaged # Add any missing dynamic libraries for unpackaged
# programs here, NOT in environment.systemPackages # programs here, NOT in environment.systemPackages
]; ];
system.stateVersion = "23.11"; # Did you read the comment? system.stateVersion = "23.11"; # Did you read the comment?
} }

View File

@ -1,34 +1,38 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ {
imports = config,
[ (modulesPath + "/installer/scan/not-detected.nix") lib,
]; pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc"];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [];
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = ["kvm-intel"];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [];
fileSystems."/" = fileSystems."/" = {
{ device = "/dev/disk/by-uuid/b57531b3-bf78-466e-a2f7-7eab09ce9284"; device = "/dev/disk/by-uuid/b57531b3-bf78-466e-a2f7-7eab09ce9284";
fsType = "ext4"; fsType = "ext4";
}; };
boot.initrd.luks.devices."luks-1ed60977-b0ee-4751-99f3-05f0b224634b".device = "/dev/disk/by-uuid/1ed60977-b0ee-4751-99f3-05f0b224634b"; boot.initrd.luks.devices."luks-1ed60977-b0ee-4751-99f3-05f0b224634b".device = "/dev/disk/by-uuid/1ed60977-b0ee-4751-99f3-05f0b224634b";
fileSystems."/boot" = fileSystems."/boot" = {
{ device = "/dev/disk/by-uuid/59A3-0BC5"; device = "/dev/disk/by-uuid/59A3-0BC5";
fsType = "vfat"; fsType = "vfat";
options = [ "fmask=0022" "dmask=0022" ]; options = ["fmask=0022" "dmask=0022"];
}; };
swapDevices = swapDevices = [
[ { device = "/dev/disk/by-uuid/968cd561-fb73-496a-a37a-0e662bf45597"; } {device = "/dev/disk/by-uuid/968cd561-fb73-496a-a37a-0e662bf45597";}
]; ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -1,93 +1,94 @@
{ config, pkgs, inputs, ... }:
{ {
# imports = [ config,
# inputs.sops-nix.nixosModules.sops pkgs,
# ]; inputs,
...
}: {
home.username = "itsscb"; home.username = "itsscb";
home.homeDirectory = "/home/itsscb"; home.homeDirectory = "/home/itsscb";
home.stateVersion = "23.11"; # Please read the comment before changing. home.stateVersion = "23.11"; # Please read the comment before changing.
programs = { programs = {
helix = { helix = {
enable = true; enable = true;
defaultEditor = true; defaultEditor = true;
settings = { settings = {
theme = "onedark"; theme = "onedark";
editor = { editor = {
line-number = "relative"; line-number = "relative";
bufferline = "multiple"; bufferline = "multiple";
auto-completion = true; auto-completion = true;
auto-save = true; auto-save = true;
auto-format = true; auto-format = true;
cursorline = true; cursorline = true;
gutters = [ gutters = [
"diff" "diff"
"diagnostics" "diagnostics"
"line-numbers" "line-numbers"
"spacer" "spacer"
]; ];
text-width = 80; text-width = 80;
cursor-shape = { cursor-shape = {
insert = "bar"; insert = "bar";
normal = "block"; normal = "block";
select = "underline"; select = "underline";
}; };
statusline = { statusline = {
left = [ left = [
"mode" "mode"
"spinner" "spinner"
"file-modification-indicator" "file-modification-indicator"
"read-only-indicator" "read-only-indicator"
]; ];
center = ["file-name"]; center = ["file-name"];
right = [ right = [
"diagnostics" "diagnostics"
"register" "register"
"selections" "selections"
"position" "position"
"file-encoding" "file-encoding"
"file-line-ending" "file-line-ending"
"file-type" "file-type"
]; ];
separator = "|"; separator = "|";
}; };
lsp = { lsp = {
enable = true; enable = true;
auto-signature-help = true; auto-signature-help = true;
display-messages = true; display-messages = true;
display-inlay-hints = true; display-inlay-hints = true;
}; };
indent-guides = { indent-guides = {
render = true; render = true;
character = ""; character = "";
skip-levels = 1; skip-levels = 1;
}; };
}; };
keys.insert.j.k="normal_mode"; keys.insert.j.k = "normal_mode";
keys.insert."C-c"="normal_mode"; keys.insert."C-c" = "normal_mode";
keys.normal.g.a = "code_action";
keys.normal.backspace = {
r = ":run-shell-command cargo run";
t = ":run-shell-command cargo test";
b = ":run-shell-command cargo build";
c = ":run-shell-command cargo check";
};
};
};
keys.normal.g.a = "code_action";
keys.normal.backspace = {
r=":run-shell-command cargo run";
t=":run-shell-command cargo test";
b=":run-shell-command cargo build";
c=":run-shell-command cargo check";
};
};
};
bash = { bash = {
enable = true; enable = true;
shellAliases = { shellAliases = {
ls = "eza -la --git"; ls = "eza -la --git";
grep = "rg";
cat = "bat"; cat = "bat";
}; };
}; };
@ -99,16 +100,14 @@
extraConfig = { extraConfig = {
credential.helper = "store"; credential.helper = "store";
}; };
# init = {
# defaultBranch = "main";
# };
}; };
vim = { vim = {
enable=true; enable = true;
}; };
chromium = { chromium = {
enable=true; enable = true;
commandLineArgs = [ commandLineArgs = [
"--disable-default-apps" "--disable-default-apps"
"--homepage https://start.duckduckgo.com" "--homepage https://start.duckduckgo.com"
@ -133,22 +132,20 @@
settings."org/gnome/desktop/background".secondary-color = "#000000"; settings."org/gnome/desktop/background".secondary-color = "#000000";
settings."org/gnome/desktop/interface".show-battery-percentage = true; settings."org/gnome/desktop/interface".show-battery-percentage = true;
settings."org/gnome/settings-daemon/plugins/media-keys".home = ["<Super>e"]; settings."org/gnome/settings-daemon/plugins/media-keys".home = ["<Super>e"];
settings."org/gnome/settings-daemon/plugins/media-keys".control-center= ["<Super>i"]; settings."org/gnome/settings-daemon/plugins/media-keys".control-center = ["<Super>i"];
settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0".binding= "<Super>t"; settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0".binding = "<Super>t";
settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0".command= "gnome-terminal"; settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0".command = "gnome-terminal";
settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0".name= "gt1"; settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0".name = "gt1";
settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1".binding= "<Control><Alt>t";
settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1".command= "gnome-terminal";
settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1".name= "gt2";
settings."org/gnome/settings-daemon/plugins/media-keys".custom-keybindings= ["/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/" "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/"];
settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1".binding = "<Control><Alt>t";
settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1".command = "gnome-terminal";
settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1".name = "gt2";
settings."org/gnome/settings-daemon/plugins/media-keys".custom-keybindings = ["/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/" "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/"];
}; };
home.packages = [ home.packages = [
]; ];
wayland.windowManager.hyprland.enable = true; wayland.windowManager.hyprland.enable = true;
wayland.windowManager.hyprland.settings = { wayland.windowManager.hyprland.settings = {
exec-once = [ exec-once = [
"swww-daemon" "swww-daemon"
"swww img /etc/nixos/dotfiles/hypr/rust.png" "swww img /etc/nixos/dotfiles/hypr/rust.png"
@ -157,11 +154,11 @@ wayland.windowManager.hyprland.settings = {
"waybar" "waybar"
"dunst" "dunst"
]; ];
"$terminal" = "alacritty"; "$terminal" = "alacritty";
"$fileManager" = "dolphin"; "$fileManager" = "dolphin";
"$menu" = "rofi -show drun"; "$menu" = "rofi -show drun";
"$mod" = "SUPER"; "$mod" = "SUPER";
monitor = ",preferred,auto,1"; monitor = ",preferred,auto,1";
@ -177,7 +174,6 @@ wayland.windowManager.hyprland.settings = {
allow_tearing = false; allow_tearing = false;
}; };
decoration = { decoration = {
rounding = 10; rounding = 10;
@ -206,7 +202,6 @@ wayland.windowManager.hyprland.settings = {
"fade, 1, 7, default" "fade, 1, 7, default"
"workspaces, 1, 6, default" "workspaces, 1, 6, default"
]; ];
}; };
gestures = { gestures = {
@ -218,14 +213,13 @@ wayland.windowManager.hyprland.settings = {
}; };
windowrulev2 = "suppressevent maximize, class:.*"; windowrulev2 = "suppressevent maximize, class:.*";
input = { input = {
follow_mouse = 2; follow_mouse = 2;
touchpad = { touchpad = {
natural_scroll = "yes"; natural_scroll = "yes";
}; };
}; };
master = { master = {
@ -236,7 +230,7 @@ wayland.windowManager.hyprland.settings = {
"$mod, mouse:272, movewindow" "$mod, mouse:272, movewindow"
"$mod, mouse:273, resizewindow" "$mod, mouse:273, resizewindow"
]; ];
bind = bind =
[ [
"$mod, T, exec, $terminal" "$mod, T, exec, $terminal"
@ -277,7 +271,7 @@ wayland.windowManager.hyprland.settings = {
10) 10)
); );
}; };
home.file = { home.file = {
".config/hypr/hyprlock.conf".source = ../../dotfiles/hypr/hyprlock.conf; ".config/hypr/hyprlock.conf".source = ../../dotfiles/hypr/hyprlock.conf;
".config/waybar".source = ../../dotfiles/waybar; ".config/waybar".source = ../../dotfiles/waybar;

52
nixos-rebuild.sh Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env bash
if [ -z "$1"]
then
file='configuration.nix'
else
file=$1
fi
# A rebuild script that commits on a successful build
set -e
# cd to your config dir
cd /etc/nixos/
# Edit your config
sudo hx $(fd $file . --max-results=1 -E hardware-configuration.nix -e nix)
# Early return if no changes were detected (thanks @singiamtel!)
if sudo git diff --quiet '*.nix'; then
echo "No changes detected, exiting."
cd -
exit 0
fi
sudo rm nixos-switch.log
# Autoformat your nix files
sudo alejandra . &>/dev/null \
|| ( sudo alejandra . ; echo "formatting failed!" && exit 1)
# Shows your changes
sudo git diff -U0 '*.nix'
echo -n "NixOS - Testing new configuration..."
# Rebuild, output simplified errors, log trackebacks
sudo nixos-rebuild dry-build --flake .#default &>nixos-switch.log || (cat nixos-switch.log | grep --color error && exit 1)
echo -e 'KNixOS - Test passed. Adding files to git'
sudo git add *
echo -e "NixOS - Rebuilding..."
sudo nixos-rebuild dry-build --flake .#default &>nixos-switch.log || (cat nixos-switch.log | grep --color error && sudo git restore --staged ./**/*.nix && cd - && exit 1)
# Get current generation metadata
current=$(sudo nixos-version --json | jq .configurationRevision)
# Commit all changes witih the generation metadata
sudo git commit -am "$current"
echo -e "NixOS - New Build commited as $current"
cd -

2
nixos-switch.log Normal file
View File

@ -0,0 +1,2 @@
building the system configuration...
warning: Git tree '/etc/nixos' is dirty

View File

@ -1,7 +1,7 @@
{ pkgs ? import <nixpkgs> {} }: {pkgs ? import <nixpkgs> {}}: let
let overrides = builtins.fromTOML (builtins.readFile ./rust-toolchain.toml);
overrides = (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml)); libPath = with pkgs;
libPath = with pkgs; lib.makeLibraryPath [ lib.makeLibraryPath [
# load external libraries that you need in your rust project here # load external libraries that you need in your rust project here
]; ];
in in
@ -14,27 +14,27 @@ in
]; ];
RUSTC_VERSION = overrides.toolchain.channel; RUSTC_VERSION = overrides.toolchain.channel;
# https://github.com/rust-lang/rust-bindgen#environment-variables # https://github.com/rust-lang/rust-bindgen#environment-variables
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ]; LIBCLANG_PATH = pkgs.lib.makeLibraryPath [pkgs.llvmPackages_latest.libclang.lib];
shellHook = '' shellHook = ''
export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/ export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/
''; '';
# Add precompiled library to rustc search path # Add precompiled library to rustc search path
RUSTFLAGS = (builtins.map (a: ''-L ${a}/lib'') [ RUSTFLAGS = builtins.map (a: ''-L ${a}/lib'') [
# add libraries here (e.g. pkgs.libvmi) # add libraries here (e.g. pkgs.libvmi)
]); ];
LD_LIBRARY_PATH = libPath; LD_LIBRARY_PATH = libPath;
# Add glibc, clang, glib, and other headers to bindgen search path # Add glibc, clang, glib, and other headers to bindgen search path
BINDGEN_EXTRA_CLANG_ARGS = BINDGEN_EXTRA_CLANG_ARGS =
# Includes normal include path # Includes normal include path
(builtins.map (a: ''-I"${a}/include"'') [ (builtins.map (a: ''-I"${a}/include"'') [
# add dev libraries here (e.g. pkgs.libvmi.dev) # add dev libraries here (e.g. pkgs.libvmi.dev)
pkgs.glibc.dev pkgs.glibc.dev
]) ])
# Includes with special directory paths # Includes with special directory paths
++ [ ++ [
''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"'' ''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"''
''-I"${pkgs.glib.dev}/include/glib-2.0"'' ''-I"${pkgs.glib.dev}/include/glib-2.0"''
''-I${pkgs.glib.out}/lib/glib-2.0/include/'' ''-I${pkgs.glib.out}/lib/glib-2.0/include/''
]; ];
} }