Nix Flakes configuration for MacOS, NixOS and WSL
0
fork

Configure Feed

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

wip: custom lib

+24 -26
+7 -7
flake.nix
··· 21 21 }; 22 22 23 23 outputs = { self, nixpkgs, darwin, ... }@inputs: 24 - let inherit (self) outputs; in 24 + let inherit (self) outputs; lib = import ./lib { inherit self inputs; }; in 25 25 { 26 26 overlays = import ./overlays { inherit inputs outputs; }; 27 27 28 28 nixosConfigurations = { 29 - loki = nixpkgs.lib.nixosSystem { 30 - system = "x86_64-linux"; 31 - specialArgs = { inherit inputs self; }; 32 - modules = [ ./hosts/x86_64-linux/loki ]; 33 - }; 29 + # loki = nixpkgs.lib.nixosSystem { 30 + # system = "x86_64-linux"; 31 + # specialArgs = { inherit inputs self; }; 32 + # modules = [ ./hosts/x86_64-linux/loki ]; 33 + # }; 34 34 35 35 # TODO: rework configuration not being usable at the moment 36 36 # nyx = nixpkgs.lib.nixosSystem { ··· 58 58 modules = [ ./hosts/aarch64-darwin/njord ]; 59 59 }; 60 60 }; 61 - }; 61 + } // (lib.host.mkHost { system = "x86_64-linux"; hostname = "loki"; path = ./hosts/x86_64-linux/loki/default.nix; }); 62 62 }
+1 -1
hosts/x86_64-linux/loki/default.nix
··· 2 2 { 3 3 imports = [ 4 4 ./hardware.nix 5 - ./../../../modules/nixos/services/window-managers/river 5 + # ./../../../modules/nixos/services/window-managers/river 6 6 inputs.home-manager.nixosModules.home-manager 7 7 ]; 8 8
+16 -18
lib/default.nix
··· 33 33 mapFile = name: type: let 34 34 path' = "${path}/${name}"; 35 35 in 36 - if type == "directory" 36 + if type |> isDirectory 37 37 then getFilesRecursively path' 38 38 else path'; 39 39 files = lib.flatten (lib.mapAttrsToList mapFile entries); ··· 45 45 46 46 ## Get all default files from a folder recursively 47 47 #@ Path -> []Path 48 - getDefaultFiles = path: getFilesRecursively path |> builtins.filter (name: builtins.basNameOf name == "default.nix"); 48 + getDefaultFiles = path: getFilesRecursively path |> builtins.filter (name: builtins.baseNameOf name == "default.nix"); 49 49 }; 50 50 51 51 module = rec { 52 - getCommonModules = getDefaultFiles ./../modules/common; 53 - getNixosModules = getDefaultFiles ./../modules/nixos ++ getCommonModules; 54 - getDarwinModules = getDefaultFiles ./../modules/darwin ++ getCommonModules; 55 - getHomeManagerModules = getDefaultFiles ./../modules/home-manager; 52 + getCommonModules = fs.getDefaultFiles ./../modules/common; 53 + getNixosModules = fs.getDefaultFiles ./../modules/nixos ++ getCommonModules; 54 + getDarwinModules = fs.getDefaultFiles ./../modules/darwin ++ getCommonModules; 55 + getHomeManagerModules = fs.getDefaultFiles ./../modules/home-manager; 56 56 }; 57 57 58 58 overlay = rec { ··· 74 74 #@ String -> [Attrs] 75 75 getSystemHostsInformations = systemPath: let 76 76 hosts = fs.getDirectories systemPath; 77 - mkHostInformations = path: rec { 78 - system = builtins.basNameOf systemPath; 79 - hostname = builtins.basNameOf path; 77 + mkHostInformations = path: { 78 + system = builtins.baseNameOf systemPath; 79 + hostname = builtins.baseNameOf path; 80 80 path = fs.getDefaultFile path; 81 - builder = getHostBuilder system; 82 - output = getHostSystemOutput system; 83 81 }; 84 82 hostsInformations = builtins.map hosts; 85 83 in hostsInformations; 86 84 87 85 ## Get the name of the system output 88 86 #@ String -> String 89 - getHostSystemOutput = system: if system |> isDarwin then "darwinConfiguration" else "NixosConfiguration"; 87 + getHostSystemOutput = system: if system |> isDarwin then "darwinConfigurations" else "nixosConfigurations"; 90 88 91 89 ## Get the system host builder 92 90 #@ String -> Functions 93 91 getHostBuilder = system: let 94 92 linuxBuilder = args: lib.nixosSystem (args // { 95 - modules = args.modules ++ []; 93 + modules = args.modules ++ module.getNixosModules; 96 94 }); 97 95 darwinBuilder = args: inputs.darwin.lib.darwinSystem (args // { 98 - modules = args.modules ++ []; 96 + modules = args.modules ++ module.getDarwinModules; 99 97 }); 100 98 in 101 99 if system |> isDarwin ··· 108 106 system, 109 107 hostname, 110 108 path, 111 - builder, 112 - output 109 + builder ? getHostBuilder system, 110 + output ? getHostSystemOutput system 113 111 }: { 114 - ${output} = ${builder} { 112 + ${output}.${hostname} = builder { 115 113 system = system; 116 114 specialArgs = { inherit inputs self; }; 117 115 modules = [ path ]; ··· 121 119 ## Create all available hosts 122 120 #@ Attrs -> Attrs 123 121 mkHosts = let 124 - systems = getDirectories ./../hosts; 122 + systems = fs.getDirectories ./../hosts; 125 123 hostsInformations = lib.concatMap getSystemHostsInformations systems; 126 124 in { 127 125