my over complex system configurations dotfiles.isabelroses.com/
nixos nix flake dotfiles linux
9
fork

Configure Feed

Select the types of activity you want to include in your feed.

flake: remove flake-parts

i was board

isabel 08965a8f bd1e56b1

+565 -508
+2 -2
.envrc
··· 5 5 # we want to track changes here, and reaload the environment 6 6 # we choose these files because they are the ones that are most likely 7 7 # to have made a change that required a shell reaload 8 - watch_dir modules/flake/programs 9 - watch_file modules/flake/args.nix 8 + watch_file modules/flake/programs/shell.nix 9 + watch_file modules/flake/programs/formatter.nix 10 10 11 11 # now we want to load the flake environment 12 12 use flake
-37
flake.lock
··· 56 56 "type": "github" 57 57 } 58 58 }, 59 - "easy-hosts": { 60 - "locked": { 61 - "lastModified": 1755470564, 62 - "narHash": "sha256-KB1ZryVDoQcbIsItOf4WtxkHhh3ppj+XwMpSnt/2QHc=", 63 - "owner": "tgirlcloud", 64 - "repo": "easy-hosts", 65 - "rev": "d0422bc7b3db26268982aa15d07e60370e76ee1d", 66 - "type": "github" 67 - }, 68 - "original": { 69 - "owner": "tgirlcloud", 70 - "repo": "easy-hosts", 71 - "type": "github" 72 - } 73 - }, 74 59 "flake-compat": { 75 60 "flake": false, 76 61 "locked": { ··· 84 69 "original": { 85 70 "owner": "NixOS", 86 71 "repo": "flake-compat", 87 - "type": "github" 88 - } 89 - }, 90 - "flake-parts": { 91 - "inputs": { 92 - "nixpkgs-lib": [ 93 - "nixpkgs" 94 - ] 95 - }, 96 - "locked": { 97 - "lastModified": 1775087534, 98 - "narHash": "sha256-91qqW8lhL7TLwgQWijoGBbiD4t7/q75KTi8NxjVmSmA=", 99 - "owner": "hercules-ci", 100 - "repo": "flake-parts", 101 - "rev": "3107b77cd68437b9a76194f0f7f9c55f2329ca5b", 102 - "type": "github" 103 - }, 104 - "original": { 105 - "owner": "hercules-ci", 106 - "repo": "flake-parts", 107 72 "type": "github" 108 73 } 109 74 }, ··· 313 278 "inputs": { 314 279 "catppuccin": "catppuccin", 315 280 "darwin": "darwin", 316 - "easy-hosts": "easy-hosts", 317 - "flake-parts": "flake-parts", 318 281 "home-manager": "home-manager", 319 282 "homebrew": "homebrew", 320 283 "izlix": "izlix",
+1 -20
flake.nix
··· 1 1 { 2 2 description = "Isabel's dotfiles"; 3 3 4 - outputs = 5 - inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } { imports = [ ./modules/flake ]; }; 4 + outputs = inputs: import ./modules/flake inputs; 6 5 7 6 inputs = { 8 7 # our main package supplier ··· 49 48 owner = "nix-community"; 50 49 repo = "home-manager"; 51 50 inputs.nixpkgs.follows = "nixpkgs"; 52 - }; 53 - 54 - ### Flake management 55 - # bring all the mess together with flake-parts 56 - flake-parts = { 57 - type = "github"; 58 - owner = "hercules-ci"; 59 - repo = "flake-parts"; 60 - inputs.nixpkgs-lib.follows = "nixpkgs"; 61 - }; 62 - 63 - # easily manage our hosts 64 - easy-hosts = { 65 - type = "github"; 66 - owner = "tgirlcloud"; 67 - repo = "easy-hosts"; 68 - 69 - # url = "git+file:/Users/isabel/dev/easy-hosts"; 70 51 }; 71 52 72 53 ### Security stuff
-25
modules/flake/args.nix
··· 1 - { inputs, ... }: 2 - { 3 - # set the output systems for this flake 4 - systems = [ 5 - "x86_64-linux" 6 - "aarch64-linux" 7 - "aarch64-darwin" 8 - ]; 9 - 10 - perSystem = 11 - { system, ... }: 12 - { 13 - # this is what controls how packages in the flake are built, but this is not passed to the 14 - # builders in lib which is important to note, since we have to do something different for 15 - # the builders to work correctly 16 - _module.args.pkgs = import inputs.nixpkgs { 17 - inherit system; 18 - config = { 19 - allowUnfree = true; 20 - allowUnsupportedSystem = true; 21 - }; 22 - overlays = [ ]; 23 - }; 24 - }; 25 - }
+19 -7
modules/flake/checks/default.nix
··· 1 - { 2 - imports = [ 3 - # keep-sorted start 4 - ./formatting.nix 5 - ./lib.nix 1 + # I would highly advise you do not use my flake as an input and instead you vendor this 2 + # if you want to use this code. 3 + { pkgs, inputs, ... }: 4 + 5 + let 6 + inherit (pkgs) lib; 7 + 8 + scope = pkgs.lib.makeScope pkgs.newScope (scopeSelf: { 9 + inherit (inputs) self; 10 + 11 + # keep-sorted start block=yes newline_separated=yes 12 + formatting = scopeSelf.callPackage ./formatting.nix { }; 13 + 14 + # lib = scopeSelf.callPackage ./lib.nix { }; 6 15 # keep-sorted end 7 - ]; 8 - } 16 + }); 17 + 18 + in 19 + 20 + lib.filterAttrs (_: lib.isDerivation) scope
+12 -13
modules/flake/checks/formatting.nix
··· 1 - { self, ... }: 2 1 { 3 - perSystem = 4 - { pkgs, config, ... }: 5 - { 6 - checks.formatting = 7 - pkgs.runCommandLocal "formatting-checks" { nativeBuildInputs = [ config.formatter ]; } 8 - '' 9 - cd ${self} 10 - treefmt --no-cache --fail-on-change 11 - touch $out 12 - ''; 13 - }; 14 - } 2 + stdenvNoCC, 3 + runCommandLocal, 4 + self, 5 + }: 6 + let 7 + fmt = self.formatter.${stdenvNoCC.hostPlatform.system}; 8 + in 9 + runCommandLocal "formatting-checks" { nativeBuildInputs = [ fmt ]; } '' 10 + cd ${self} 11 + treefmt --no-cache --fail-on-change 12 + touch $out 13 + ''
+97 -99
modules/flake/checks/lib.nix
··· 1 - { lib, self, ... }: 2 1 { 3 - perSystem = 4 - { pkgs, ... }: 5 - let 6 - res = lib.debug.runTests { 7 - boolToNum = { 8 - expr = self.lib.helpers.boolToNum true; 9 - expected = 1; 10 - }; 2 + lib, 3 + deepdiff, 4 + runCommandLocal, 5 + self, 6 + }: 7 + let 8 + res = lib.debug.runTests { 9 + boolToNum = { 10 + expr = self.lib.helpers.boolToNum true; 11 + expected = 1; 12 + }; 11 13 12 - intListToStringList = { 13 - expr = self.lib.helpers.intListToStringList [ 14 - 1 15 - 2 16 - 3 17 - ]; 18 - expected = [ 19 - "1" 20 - "2" 21 - "3" 22 - ]; 23 - }; 14 + intListToStringList = { 15 + expr = self.lib.helpers.intListToStringList [ 16 + 1 17 + 2 18 + 3 19 + ]; 20 + expected = [ 21 + "1" 22 + "2" 23 + "3" 24 + ]; 25 + }; 24 26 25 - indexOf = { 26 - expr = self.lib.helpers.indexOf [ 27 - 1 28 - 2 29 - 3 30 - ] 2; 31 - expected = 1; 32 - }; 27 + indexOf = { 28 + expr = self.lib.helpers.indexOf [ 29 + 1 30 + 2 31 + 3 32 + ] 2; 33 + expected = 1; 34 + }; 33 35 34 - containsStrings = { 35 - expr = 36 - self.lib.helpers.containsStrings 37 - [ 38 - "a" 39 - "b" 40 - "c" 41 - ] 42 - [ 43 - "a" 44 - "b" 45 - ]; 46 - expected = true; 47 - }; 36 + containsStrings = { 37 + expr = 38 + self.lib.helpers.containsStrings 39 + [ 40 + "a" 41 + "b" 42 + "c" 43 + ] 44 + [ 45 + "a" 46 + "b" 47 + ]; 48 + expected = true; 49 + }; 48 50 49 - giturl = { 50 - expr = self.lib.helpers.giturl { 51 - domain = "github.com"; 52 - alias = "gh"; 53 - }; 54 - expected = { 55 - "https://github.com/".insteadOf = "gh:"; 56 - "ssh://git@github.com/".pushInsteadOf = "gh:"; 57 - }; 58 - }; 51 + giturl = { 52 + expr = self.lib.helpers.giturl { 53 + domain = "github.com"; 54 + alias = "gh"; 55 + }; 56 + expected = { 57 + "https://github.com/".insteadOf = "gh:"; 58 + "ssh://git@github.com/".pushInsteadOf = "gh:"; 59 + }; 60 + }; 59 61 60 - mkPub = { 61 - expr = self.lib.helpers.mkPub "github.com" { 62 - type = "rsa"; 63 - key = "AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=="; 64 - }; 65 - expected = { 66 - "github.com-rsa" = { 67 - hostNames = [ "github.com" ]; 68 - publicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=="; 69 - }; 70 - }; 62 + mkPub = { 63 + expr = self.lib.helpers.mkPub "github.com" { 64 + type = "rsa"; 65 + key = "AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=="; 66 + }; 67 + expected = { 68 + "github.com-rsa" = { 69 + hostNames = [ "github.com" ]; 70 + publicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=="; 71 71 }; 72 72 }; 73 + }; 74 + }; 73 75 74 - # modified from 75 - # https://github.com/antifuchs/nix-flake-tests/blob/bbd9216bd0f6495bb961a8eb8392b7ef55c67afb/default.nix 76 - formatValue = 77 - val: if (builtins.isList val || builtins.isAttrs val) then builtins.toJSON val else toString val; 76 + # modified from 77 + # https://github.com/antifuchs/nix-flake-tests/blob/bbd9216bd0f6495bb961a8eb8392b7ef55c67afb/default.nix 78 + formatValue = 79 + val: if (builtins.isList val || builtins.isAttrs val) then builtins.toJSON val else toString val; 78 80 79 - resultToString = 80 - { 81 - name, 82 - expected, 83 - result, 84 - }: 85 - builtins.readFile ( 86 - pkgs.runCommandLocal "nix-flake-tests-error" 87 - { 88 - expected = formatValue expected; 89 - result = formatValue result; 90 - passAsFile = [ 91 - "expected" 92 - "result" 93 - ]; 94 - } 95 - '' 96 - echo "${name} failed (- expected, + result)" > $out 97 - cp ''${expectedPath} ''${expectedPath}.json 98 - cp ''${resultPath} ''${resultPath}.json 99 - ${pkgs.deepdiff}/bin/deep diff ''${expectedPath}.json ''${resultPath}.json >> $out 100 - '' 101 - ); 102 - in 81 + resultToString = 103 82 { 104 - checks.lib = 105 - if res != [ ] then 106 - throw (lib.strings.concatStringsSep "\n" (map resultToString (lib.debug.traceValSeq res))) 107 - else 108 - pkgs.runCommandLocal "nix-flake-tests-success" { } "echo > $out"; 109 - }; 110 - } 83 + name, 84 + expected, 85 + result, 86 + }: 87 + builtins.readFile ( 88 + runCommandLocal "nix-flake-tests-error" 89 + { 90 + expected = formatValue expected; 91 + result = formatValue result; 92 + passAsFile = [ 93 + "expected" 94 + "result" 95 + ]; 96 + } 97 + '' 98 + echo "${name} failed (- expected, + result)" > $out 99 + cp ''${expectedPath} ''${expectedPath}.json 100 + cp ''${resultPath} ''${resultPath}.json 101 + ${deepdiff}/bin/deep diff ''${expectedPath}.json ''${resultPath}.json >> $out 102 + '' 103 + ); 104 + in 105 + if res != [ ] then 106 + throw (lib.strings.concatStringsSep "\n" (map resultToString (lib.debug.traceValSeq res))) 107 + else 108 + runCommandLocal "nix-flake-tests-success" { } "echo > $out"
+91 -9
modules/flake/default.nix
··· 1 + inputs: 2 + 3 + let 4 + 5 + inherit (inputs) nixpkgs self; 6 + inherit (nixpkgs) lib; 7 + 8 + systems = [ 9 + "x86_64-linux" 10 + "aarch64-linux" 11 + "aarch64-darwin" 12 + ]; 13 + 14 + forAllSystems = fn: lib.genAttrs systems (system: fn nixpkgs.legacyPackages.${system}); 15 + 16 + mkHosts = lib.mapAttrs self.lib.mkHost; 17 + in 18 + 1 19 { 2 - imports = [ 3 - # keep-sorted start prefix_order=../../,./ 4 - ../../systems 5 - ./args.nix # the base args that is passed to the flake 6 - ./checks # custom checks that are devised to test if the system is working as expected 7 - ./lib # the lib that is used in the system 8 - ./packages # our custom packages provided by the flake 9 - ./programs # programs that run in the dev shell 20 + # a raw unfilted scope of packages 21 + legacyPackages = forAllSystems (pkgs: import ./packages { inherit pkgs inputs; }); 22 + 23 + packages = forAllSystems ( 24 + pkgs: 25 + lib.filterAttrs ( 26 + _: pkg: 27 + let 28 + isDerivation = lib.isDerivation pkg; 29 + availableOnHost = lib.meta.availableOn pkgs.stdenv.hostPlatform pkg; 30 + isBroken = pkg.meta.broken or false; 31 + in 32 + isDerivation && !isBroken && availableOnHost 33 + ) self.legacyPackages.${pkgs.stdenv.hostPlatform.system} 34 + ); 35 + 36 + # get a list of packages for the host system, and if none exist use an empty set 37 + overlays.default = _: prev: self.packages.${prev.stdenv.hostPlatform.system} or { }; 38 + 39 + devShells = forAllSystems (pkgs: { 40 + default = pkgs.callPackage ./programs/shell.nix { 41 + treefmt-wrapped = self.formatter.${pkgs.stdenv.hostPlatform.system}; 42 + }; 43 + }); 44 + 45 + lib = import ./lib { inherit lib inputs; }; 46 + 47 + checks = forAllSystems (pkgs: import ./checks { inherit pkgs inputs; }); 48 + 49 + formatter = forAllSystems (pkgs: pkgs.callPackage ./programs/formatter.nix { }); 50 + 51 + # This is the list of system configuration 52 + # 53 + # the defaults consists of the following: 54 + # arch = "x86_64"; 55 + # class = "nixos"; 56 + # modules = [ ]; 57 + # specialArgs = { }; 58 + nixosConfigurations = mkHosts { 59 + # keep-sorted start block=yes newline_separated=yes 60 + amaterasu = { }; 61 + 62 + aphrodite = { }; 63 + 64 + athena = { }; 65 + 66 + hephaestus = { }; 67 + 68 + isis = { }; 69 + 70 + lilith = { 71 + class = "iso"; 72 + }; 73 + 74 + minerva = { }; 75 + 76 + skadi = { 77 + arch = "aarch64"; 78 + }; 79 + 80 + valkyrie = { 81 + class = "wsl"; 82 + }; 10 83 # keep-sorted end 11 - ]; 84 + }; 85 + 86 + darwinConfigurations = mkHosts { 87 + # keep-sorted start block=yes newline_separated=yes 88 + tatsumaki = { 89 + arch = "aarch64"; 90 + class = "darwin"; 91 + }; 92 + #keep-sorted end 93 + }; 12 94 }
+35 -39
modules/flake/lib/default.nix
··· 1 1 # following https://github.com/NixOS/nixpkgs/blob/77ee426a4da240c1df7e11f48ac6243e0890f03e/lib/default.nix 2 2 # as a rough template we can create our own extensible lib and expose it to the flake 3 3 # we can then use that elsewhere like our hosts 4 - { lib, inputs, ... }: 5 - let 6 - gardenLib = lib.fixedPoints.makeExtensible (final: { 7 - # keep-sorted start block=yes 8 - hardware = import ./hardware.nix; 9 - helpers = import ./helpers.nix { inherit lib; }; 10 - secrets = import ./secrets.nix { inherit inputs; }; 11 - services = import ./services.nix { inherit lib; }; 12 - template = import ./template; # templates, selections of code that are repeated 13 - validators = import ./validators.nix { inherit lib; }; 14 - # keep-sorted end 4 + { lib, inputs }: 15 5 16 - # we have to rexport the functions we want to use, but don't want to refer to the whole lib 17 - # "path". e.g. gardenLib.hardware.isx86Linux can be shortened to gardenLib.isx86Linux 18 - # NOTE: never rexport templates 19 - inherit (final.hardware) isx86Linux ldTernary; 20 - inherit (final.helpers) 21 - mkPubs 22 - giturl 23 - filterNixFiles 24 - importNixFiles 25 - importNixFilesAndDirs 26 - boolToNum 27 - containsStrings 28 - indexOf 29 - intListToStringList 30 - ; 31 - inherit (final.secrets) mkSecret; 32 - inherit (final.services) mkGraphicalService mkServiceOption; 33 - inherit (final.validators) 34 - ifTheyExist 35 - ifOneEnabled 36 - anyHome 37 - ; 38 - }); 39 - in 40 - { 41 - # expose our custom lib to the flake 42 - flake.lib = gardenLib; 43 - } 6 + lib.fixedPoints.makeExtensible (final: { 7 + # keep-sorted start block=yes 8 + hardware = import ./hardware.nix; 9 + helpers = import ./helpers.nix { inherit lib; }; 10 + mkHost = import ./mkhost.nix { inherit inputs lib; }; 11 + secrets = import ./secrets.nix { inherit inputs; }; 12 + services = import ./services.nix { inherit lib; }; 13 + template = import ./template; # templates, selections of code that are repeated 14 + validators = import ./validators.nix { inherit lib; }; 15 + # keep-sorted end 16 + 17 + # we have to rexport the functions we want to use, but don't want to refer to the whole lib 18 + # "path". e.g. gardenLib.hardware.isx86Linux can be shortened to gardenLib.isx86Linux 19 + # NOTE: never rexport templates 20 + inherit (final.hardware) isx86Linux ldTernary; 21 + inherit (final.helpers) 22 + mkPubs 23 + giturl 24 + filterNixFiles 25 + importNixFiles 26 + importNixFilesAndDirs 27 + boolToNum 28 + containsStrings 29 + indexOf 30 + intListToStringList 31 + ; 32 + inherit (final.secrets) mkSecret; 33 + inherit (final.services) mkGraphicalService mkServiceOption; 34 + inherit (final.validators) 35 + ifTheyExist 36 + ifOneEnabled 37 + anyHome 38 + ; 39 + })
+153
modules/flake/lib/mkhost.nix
··· 1 + { 2 + lib, 3 + inputs, 4 + }: 5 + let 6 + inherit (inputs) self; 7 + 8 + inherit (lib) 9 + optionals 10 + singleton 11 + concatLists 12 + recursiveUpdate 13 + mapAttrs 14 + ; 15 + in 16 + /** 17 + mkHost is a function that uses withSystem to give us inputs' and self' 18 + it also assumes the the system type either nixos or darwin and uses the appropriate 19 + 20 + # Type 21 + 22 + ``` 23 + mkHost :: String -> AttrSet -> AttrSet 24 + ``` 25 + 26 + # Example 27 + 28 + ```nix 29 + mkHost "myhost" { 30 + arch = "x86_64"; 31 + class = "nixos"; 32 + modules = [ ./module.nix ]; 33 + specialArgs = { foo = "bar"; }; 34 + } 35 + ``` 36 + */ 37 + name: 38 + { 39 + arch ? "x86_64", 40 + class ? "nixos", 41 + modules ? [ ], 42 + specialArgs ? { }, 43 + ... 44 + }: 45 + let 46 + inherit (inputs) darwin nixpkgs; 47 + 48 + os = 49 + { 50 + iso = "linux"; 51 + wsl = "linux"; 52 + nixos = "linux"; 53 + } 54 + .${class} or class; 55 + system = "${arch}-${os}"; 56 + 57 + evalHost = if class == "darwin" then darwin.lib.darwinSystem else nixpkgs.lib.nixosSystem; 58 + in 59 + evalHost { 60 + # we use recursiveUpdate such that users can "override" the specialArgs 61 + # 62 + # This should only be used for special arguments that need to be evaluated 63 + # when resolving module structure (like in imports). 64 + specialArgs = recursiveUpdate { 65 + inherit 66 + # these are normal args that people expect to be passed, 67 + # but we expect to be evaluated when resolving module structure 68 + inputs 69 + 70 + # even though self is just the same as `inputs.self` 71 + # we still pass this as some people will use this 72 + self 73 + ; 74 + } specialArgs; 75 + 76 + modules = concatLists [ 77 + [ 78 + # import our host system paths 79 + "${self}/systems/${name}/default.nix" 80 + 81 + # import the files required for the class 82 + "${self}/modules/${class}/default.nix" 83 + ] 84 + 85 + # get an installer profile from nixpkgs to base the Isos off of 86 + # this is useful because it makes things alot easier 87 + (optionals (class == "iso") [ 88 + "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix" 89 + ]) 90 + 91 + # the next 3 singleton's are split up to make it easier to understand as they do things different things 92 + 93 + # recall `specialArgs` would take be preferred when resolving module structure 94 + # well this is how we do it use it for all args that don't need to rosolve module structure 95 + (singleton ( 96 + { config, ... }: 97 + let 98 + inputs' = mapAttrs (_: mapAttrs (_: v: v.${config.nixpkgs.hostPlatform.system} or v)) inputs; 99 + in 100 + { 101 + key = "dotfiles#specialArgs"; 102 + _file = "${__curPos.file}"; 103 + 104 + _module.args = { 105 + inherit inputs'; 106 + self' = inputs'.self; 107 + }; 108 + } 109 + )) 110 + 111 + # here we make some basic assumptions about the system the person is using 112 + # like the system type and the hostname 113 + (singleton { 114 + key = "dotfiles#hostname"; 115 + _file = "${__curPos.file}"; 116 + 117 + # we set the systems hostname based on the host value 118 + # which should be a string that is the hostname of the system 119 + networking.hostName = name; 120 + }) 121 + 122 + (singleton { 123 + key = "dotfiles#nixpkgs"; 124 + _file = "${__curPos.file}"; 125 + 126 + nixpkgs = { 127 + # you can also do this as `inherit system;` with the normal `lib.nixosSystem` 128 + # however for evalModules this will not work, so we do this instead 129 + hostPlatform = system; 130 + 131 + # The path to the nixpkgs sources used to build the system. 132 + # This is automatically set up to be the store path of the nixpkgs flake used to build 133 + # the system if using lib.nixosSystem, and is otherwise null by default. 134 + # so that means that we should set it to our nixpkgs flake output path 135 + flake.source = nixpkgs.outPath; 136 + }; 137 + }) 138 + 139 + # if we are on darwin we need to import the nixpkgs source, its used in some 140 + # modules, if this is not set then you will get an error 141 + (optionals (class == "darwin") (singleton { 142 + key = "dotfiles#nixpkgs-darwin"; 143 + _file = "${__curPos.file}"; 144 + 145 + # without supplying an upstream nixpkgs source, nix-darwin will not be able to build 146 + # and will complain and log an error demanding that you must set this value 147 + nixpkgs.source = nixpkgs; 148 + })) 149 + 150 + # import any additional modules that the user has provided 151 + modules 152 + ]; 153 + }
+12 -36
modules/flake/packages/default.nix
··· 1 1 # I would highly advise you do not use my flake as an input and instead you vendor this 2 - # if you want to use this code, you may want to add my cachix cache to your flake 3 - # you may want to not have to build this for yourself however 4 - { lib, inputs, ... }: 5 - { 6 - # get a list of packages for the host system, and if none exist use an empty set 7 - flake.overlays.default = _: prev: inputs.self.packages.${prev.stdenv.hostPlatform.system} or { }; 8 - 9 - perSystem = 10 - { 11 - pkgs, 12 - inputs', 13 - ... 14 - }: 15 - let 16 - packages = lib.makeScope pkgs.newScope (self: { 17 - inherit inputs; 2 + # if you want to use this code. 3 + { pkgs, inputs, ... }: 18 4 19 - # keep-sorted start block=yes newline_separated=yes 20 - docs = self.callPackage ./docs/package.nix { }; 5 + pkgs.lib.makeScope pkgs.newScope (self: { 6 + inherit inputs; 21 7 22 - iztaller = self.callPackage ./iztaller/package.nix { nix = inputs'.izlix.packages.lix; }; 8 + # keep-sorted start block=yes newline_separated=yes 9 + docs = self.callPackage ./docs/package.nix { }; 23 10 24 - libdoc = self.callPackage ./docs/lib.nix { }; 25 - # keep-sorted end 26 - }); 27 - in 28 - { 29 - legacyPackages = packages; 11 + iztaller = self.callPackage ./iztaller/package.nix { 12 + nix = inputs.izlix.packages.${pkgs.stdenv.hostPlatform.system}.lix; 13 + }; 30 14 31 - packages = lib.filterAttrs ( 32 - _: pkg: 33 - let 34 - isDerivation = lib.isDerivation pkg; 35 - availableOnHost = lib.meta.availableOn pkgs.stdenv.hostPlatform pkg; 36 - isBroken = pkg.meta.broken or false; 37 - in 38 - isDerivation && !isBroken && availableOnHost 39 - ) packages; 40 - }; 41 - } 15 + libdoc = self.callPackage ./docs/lib.nix { }; 16 + # keep-sorted end 17 + })
-8
modules/flake/programs/default.nix
··· 1 - { 2 - imports = [ 3 - # keep-sorted start 4 - ./formatter.nix # formatter for nix fmt, via treefmt is a formatter for every language 5 - ./shell.nix # a dev shell that provieds all that you will need to work 6 - # keep-sorted end 7 - ]; 8 - }
+120 -111
modules/flake/programs/formatter.nix
··· 1 - { lib, ... }: 2 1 { 3 - perSystem = 4 - { pkgs, ... }: 5 - { 6 - formatter = pkgs.treefmt.withConfig { 7 - runtimeInputs = with pkgs; [ 8 - # keep-sorted start 9 - actionlint 10 - deadnix 11 - keep-sorted 12 - nixfmt 13 - shellcheck 14 - shfmt 15 - statix 16 - stylua 17 - taplo 18 - yamlfmt 19 - zizmor 20 - # keep-sorted end 2 + lib, 3 + treefmt, 4 + actionlint, 5 + deadnix, 6 + keep-sorted, 7 + nixfmt, 8 + shellcheck, 9 + shfmt, 10 + statix, 11 + stylua, 12 + taplo, 13 + yamlfmt, 14 + zizmor, 15 + writeShellScriptBin, 16 + }: 17 + treefmt.withConfig { 18 + runtimeInputs = [ 19 + # keep-sorted start 20 + actionlint 21 + deadnix 22 + keep-sorted 23 + nixfmt 24 + shellcheck 25 + shfmt 26 + statix 27 + stylua 28 + taplo 29 + yamlfmt 30 + zizmor 31 + # keep-sorted end 21 32 22 - (writeShellScriptBin "statix-fix" '' 23 - for file in "$@"; do 24 - ${lib.getExe statix} fix "$file" 25 - done 26 - '') 27 - ]; 33 + (writeShellScriptBin "statix-fix" '' 34 + for file in "$@"; do 35 + ${lib.getExe statix} fix "$file" 36 + done 37 + '') 38 + ]; 28 39 29 - settings = { 30 - on-unmatched = "info"; 31 - tree-root-file = "flake.nix"; 40 + settings = { 41 + on-unmatched = "info"; 42 + tree-root-file = "flake.nix"; 32 43 33 - excludes = [ "secrets/*" ]; 44 + excludes = [ "secrets/*" ]; 34 45 35 - formatter = { 36 - # keep-sorted start block=yes newline_separated=yes 37 - actionlint = { 38 - command = "actionlint"; 39 - includes = [ 40 - ".github/workflows/*.yml" 41 - ".github/workflows/*.yaml" 42 - ]; 43 - }; 46 + formatter = { 47 + # keep-sorted start block=yes newline_separated=yes 48 + actionlint = { 49 + command = "actionlint"; 50 + includes = [ 51 + ".github/workflows/*.yml" 52 + ".github/workflows/*.yaml" 53 + ]; 54 + }; 44 55 45 - deadnix = { 46 - command = "deadnix"; 47 - options = [ "--edit" ]; 48 - includes = [ "*.nix" ]; 49 - }; 56 + deadnix = { 57 + command = "deadnix"; 58 + options = [ "--edit" ]; 59 + includes = [ "*.nix" ]; 60 + }; 50 61 51 - keep-sorted = { 52 - command = "keep-sorted"; 53 - includes = [ "*" ]; 54 - }; 62 + keep-sorted = { 63 + command = "keep-sorted"; 64 + includes = [ "*" ]; 65 + }; 55 66 56 - nixfmt = { 57 - command = "nixfmt"; 58 - includes = [ "*.nix" ]; 59 - }; 67 + nixfmt = { 68 + command = "nixfmt"; 69 + includes = [ "*.nix" ]; 70 + }; 60 71 61 - shellcheck = { 62 - command = "shellcheck"; 63 - includes = [ 64 - "*.sh" 65 - "*.bash" 66 - # direnv 67 - "*.envrc" 68 - "*.envrc.*" 69 - ]; 70 - }; 72 + shellcheck = { 73 + command = "shellcheck"; 74 + includes = [ 75 + "*.sh" 76 + "*.bash" 77 + # direnv 78 + "*.envrc" 79 + "*.envrc.*" 80 + ]; 81 + }; 71 82 72 - shfmt = { 73 - command = "shfmt"; 74 - options = [ 75 - "-s" 76 - "-w" 77 - "-i" 78 - "2" 79 - ]; 80 - includes = [ 81 - "*.sh" 82 - "*.bash" 83 - # direnv 84 - "*.envrc" 85 - "*.envrc.*" 86 - ]; 87 - }; 83 + shfmt = { 84 + command = "shfmt"; 85 + options = [ 86 + "-s" 87 + "-w" 88 + "-i" 89 + "2" 90 + ]; 91 + includes = [ 92 + "*.sh" 93 + "*.bash" 94 + # direnv 95 + "*.envrc" 96 + "*.envrc.*" 97 + ]; 98 + }; 88 99 89 - statix = { 90 - command = "statix-fix"; 91 - includes = [ "*.nix" ]; 92 - }; 100 + statix = { 101 + command = "statix-fix"; 102 + includes = [ "*.nix" ]; 103 + }; 93 104 94 - stylua = { 95 - command = "stylua"; 96 - includes = [ "*.lua" ]; 97 - }; 105 + stylua = { 106 + command = "stylua"; 107 + includes = [ "*.lua" ]; 108 + }; 98 109 99 - taplo = { 100 - command = "taplo"; 101 - options = "format"; 102 - includes = [ "*.toml" ]; 103 - }; 110 + taplo = { 111 + command = "taplo"; 112 + options = "format"; 113 + includes = [ "*.toml" ]; 114 + }; 104 115 105 - yamlfmt = { 106 - command = "yamlfmt"; 107 - options = [ 108 - "-formatter" 109 - "retain_line_breaks_single=true" 110 - ]; 111 - includes = [ 112 - "*.yml" 113 - "*.yaml" 114 - ]; 115 - }; 116 + yamlfmt = { 117 + command = "yamlfmt"; 118 + options = [ 119 + "-formatter" 120 + "retain_line_breaks_single=true" 121 + ]; 122 + includes = [ 123 + "*.yml" 124 + "*.yaml" 125 + ]; 126 + }; 116 127 117 - zizmor = { 118 - command = "zizmor"; 119 - includes = [ 120 - ".github/workflows/*.yml" 121 - ".github/workflows/*.yaml" 122 - ]; 123 - }; 124 - # keep-sorted end 125 - }; 126 - }; 128 + zizmor = { 129 + command = "zizmor"; 130 + includes = [ 131 + ".github/workflows/*.yml" 132 + ".github/workflows/*.yaml" 133 + ]; 127 134 }; 135 + # keep-sorted end 128 136 }; 137 + }; 129 138 }
+19 -44
modules/flake/programs/shell.nix
··· 1 1 { 2 - perSystem = 3 - { 4 - pkgs, 5 - config, 6 - ... 7 - }: 8 - { 9 - devShells = { 10 - default = pkgs.mkShellNoCC { 11 - name = "dotfiles"; 12 - meta.description = "Development shell for this configuration"; 2 + mkShellNoCC, 3 + just, 4 + gitMinimal, 5 + sops, 6 + nix-output-monitor, 7 + treefmt-wrapped, 8 + }: 9 + mkShellNoCC { 10 + name = "dotfiles"; 13 11 14 - DIRENV_LOG_FORMAT = ""; 12 + packages = [ 13 + just # quick and easy task runner 14 + gitMinimal # we need git 15 + sops # secrets management 16 + treefmt-wrapped # nix formatter 17 + nix-output-monitor # get clean diff between generations 18 + ]; 15 19 16 - packages = [ 17 - pkgs.just # quick and easy task runner 18 - pkgs.gitMinimal # we need git 19 - pkgs.sops # secrets management 20 - config.formatter # nix formatter 21 - pkgs.nix-output-monitor # get clean diff between generations 22 - ]; 20 + inputsFrom = [ treefmt-wrapped ]; 23 21 24 - inputsFrom = [ config.formatter ]; 25 - }; 26 - 27 - nixpkgs = pkgs.mkShellNoCC { 28 - packages = builtins.attrValues { 29 - inherit (pkgs) 30 - # package creation helpers 31 - nurl 32 - nix-init 22 + env.DIRENV_LOG_FORMAT = ""; 33 23 34 - # nixpkgs dev stuff 35 - hydra-check 36 - nixpkgs-lint 37 - nixpkgs-review 38 - nixpkgs-hammering 39 - 40 - # nix helpers 41 - nix-melt 42 - nix-tree 43 - nix-inspect 44 - nix-search-cli 45 - ; 46 - }; 47 - }; 48 - }; 49 - }; 24 + meta.description = "Development shell for this configuration"; 50 25 }
-57
systems/default.nix
··· 1 - { self, inputs, ... }: 2 - { 3 - imports = [ inputs.easy-hosts.flakeModule ]; 4 - 5 - config.easy-hosts = { 6 - additionalClasses = { 7 - wsl = "nixos"; 8 - }; 9 - 10 - perClass = class: { 11 - modules = [ 12 - # import the class module, this contains the common configurations between all systems of the same class 13 - "${self}/modules/${class}/default.nix" 14 - ]; 15 - }; 16 - 17 - # This is the list of system configuration 18 - # 19 - # the defaults consists of the following: 20 - # arch = "x86_64"; 21 - # class = "nixos"; 22 - # modules = [ ]; 23 - # specialArgs = { }; 24 - hosts = { 25 - # keep-sorted start block=yes newline_separated=yes 26 - amaterasu = { }; 27 - 28 - aphrodite = { }; 29 - 30 - athena = { }; 31 - 32 - hephaestus = { }; 33 - 34 - isis = { }; 35 - 36 - lilith = { 37 - class = "iso"; 38 - }; 39 - 40 - minerva = { }; 41 - 42 - skadi = { 43 - arch = "aarch64"; 44 - }; 45 - 46 - tatsumaki = { 47 - arch = "aarch64"; 48 - class = "darwin"; 49 - }; 50 - 51 - valkyrie = { 52 - class = "wsl"; 53 - }; 54 - # keep-sorted end 55 - }; 56 - }; 57 - }
-1
systems/lilith/README.md
··· 1 - Most the code from here has been refactored out into [the iso module](../../modules/iso) this directory still exists in case I need to add more isos or specific overrides.
+4
systems/lilith/default.nix
··· 1 + # Most the code from here has been refactored out into [the iso 2 + # module](../../modules/iso) this directory still exists in case I need to add 3 + # more isos or specific overrides. 4 + { }