nix machine / user configurations
1{ 2 inputs, 3 config, 4 pkgs, 5 lib, 6 tlib, 7 ... 8}: 9let 10 inherit (lib) fileContents mkIf; 11 12 coreBin = v: "${pkgs.coreutils}/bin/${v}"; 13 nixBin = "${config.nix.package}/bin/nix"; 14 pkgBin = tlib.pkgBin; 15in 16{ 17 imports = [ 18 ./nix.nix 19 ./hm-system-defaults.nix 20 ]; 21 22 environment = { 23 systemPackages = with pkgs; [ 24 binutils 25 coreutils 26 curl 27 direnv 28 dnsutils 29 dosfstools 30 fd 31 bottom 32 gptfdisk 33 iputils 34 jq 35 manix 36 moreutils 37 nix-index 38 nmap 39 ripgrep 40 skim 41 tealdeer 42 usbutils 43 util-linux 44 whois 45 bat 46 fzf 47 eza 48 lm_sensors 49 mkpasswd 50 bottom 51 amber 52 unzip 53 unrar 54 hydra-check 55 du-dust 56 mosh 57 git 58 git-crypt 59 ]; 60 shellAliases = 61 let 62 ifSudo = string: mkIf config.security.sudo.enable string; 63 inherit (pkgs) 64 git 65 bat 66 eza 67 du-dust 68 ; 69 in 70 { 71 g = pkgBin git; 72 git-optimize = "${pkgBin git} gc --aggressive --prune=now"; 73 cat = "${pkgBin bat} -pp --theme=base16"; 74 c = "cat"; 75 du = "${pkgBin du-dust}"; 76 df = "${coreBin "df"} -h"; 77 free = "${pkgs.procps}/bin/free -h"; 78 ls = pkgBin eza; 79 l = "${pkgBin eza} -lhg"; 80 la = "${pkgBin eza} -lhg -a"; 81 t = "${pkgBin eza} -lhg -T"; 82 ta = "${pkgBin eza} -lhg -a -T"; 83 n = nixBin; 84 nb = "${nixBin} build"; 85 nf = "${nixBin} flake"; 86 nfu = "${nixBin} flake update"; 87 nfui = "${nixBin} flake update"; 88 nfs = "${nixBin} flake show"; 89 nsh = "${nixBin} shell"; 90 nix-store-refs = "nix-store -qR"; 91 nosrs = ifSudo "sudo nixos-rebuild --fast switch"; 92 nosrb = ifSudo "sudo nixos-rebuild --fast boot"; 93 nosrt = ifSudo "sudo nixos-rebuild --fast test"; 94 ngc = ifSudo "sudo nix-collect-garbage"; 95 ngcdo = ifSudo "sudo nix-collect-garbage --delete-old"; 96 top = "${pkgs.bottom}/bin/btm"; 97 myip = "${pkgs.dnsutils}/bin/dig +short myip.opendns.com @208.67.222.222 2>&1"; 98 mn = 99 let 100 manix_preview = "manix '{}' | sed 's/type: /> type: /g' | bat -l Markdown --color=always --plain"; 101 in 102 ''manix "" | rg '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | sk --preview="${manix_preview}" | xargs manix''; 103 # systemd 104 ctl = "systemctl"; 105 stl = ifSudo "s systemctl"; 106 utl = "systemctl --user"; 107 jtl = "journalctl"; 108 }; 109 }; 110 system.activationScripts.diff = '' 111 if [ -z "$systemConfig" ]; then 112 ${config.nix.package}/bin/nix store \ 113 --experimental-features 'nix-command' \ 114 diff-closures /run/current-system "$systemConfig" 115 fi 116 ''; 117 users.mutableUsers = false; 118 programs = { 119 command-not-found.enable = true; 120 git = { 121 enable = true; 122 config = { 123 safe.directory = [ "/etc/nixos" ]; 124 }; 125 }; 126 }; 127}