From 6c6a8497124978bf85b69e060c3060418f104c73 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Mon, 9 Dec 2024 15:20:05 +1100 Subject: [PATCH] 32 papercuts --- CHANGELOG.md | 5 + files/no-ifd.diff | 32 +- flake.lock | 71 ++++ flake.nix | 556 +++++++++++++------------ hosts/sigma/hardware-configuration.nix | 4 +- modules/base.nix | 6 +- modules/clan.nix | 7 + modules/flakes.nix | 2 +- 8 files changed, 395 insertions(+), 288 deletions(-) create mode 100644 modules/clan.nix diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e4d695..317fcad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +- Changed `no-ifd` patch to change `hosts/hermes/hardware-configuration.nix` instead of `flake.nix` to reduce churn +- Added `formatter` flake output to support `nix fmt` +- Refactored `mkConfigurations` to be inside `flake-parts.lib.mkFlake` +- Use `clan` to deploy to `sigma` +- Use renamed `nixfmt-classic` instead of `nixfmt` - Added `deploy-` packages for remotely deploying macOS machines - Use Microsoft's Python VSCode extension for Python IDE functionality - Use `gitlens.remotes` to support `git.clan.lol` diff --git a/files/no-ifd.diff b/files/no-ifd.diff index ac1ec6e..3143e04 100644 --- a/files/no-ifd.diff +++ b/files/no-ifd.diff @@ -1,19 +1,13 @@ -diff --git a/flake.nix b/flake.nix -index cf8fbb7..cad4e0a 100644 ---- a/flake.nix -+++ b/flake.nix -@@ -286,14 +286,6 @@ - inherit (modules) laptop linux-builder personal; - }; - } -- { -- host = "hermes"; -- hostSuffix = "-nixos"; -- user = "enzime"; -- system = "aarch64-linux"; -- modules = -- builtins.attrNames { inherit (modules) laptop personal sway; }; -- } - { - host = "phi"; - hostSuffix = "-nixos"; +diff --git a/hosts/hermes/hardware-configuration.nix b/hosts/hermes/hardware-configuration.nix +index 5e5fdf9..738de1b 100644 +--- a/hosts/hermes/hardware-configuration.nix ++++ b/hosts/hermes/hardware-configuration.nix +@@ -26,7 +26,7 @@ + swapDevices = [{ device = "/dev/pool/swap"; }]; + + hardware.asahi.useExperimentalGPUDriver = true; +- hardware.asahi.experimentalGPUInstallMode = "replace"; ++ hardware.asahi.experimentalGPUInstallMode = "overlay"; + + powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand"; + } diff --git a/flake.lock b/flake.lock index c8edd81..3d5f551 100644 --- a/flake.lock +++ b/flake.lock @@ -29,6 +29,40 @@ "type": "github" } }, + "clan-core": { + "inputs": { + "disko": [ + "disko" + ], + "flake-parts": [ + "flake-parts" + ], + "nixos-facter-modules": "nixos-facter-modules", + "nixpkgs": [ + "nixpkgs" + ], + "sops-nix": "sops-nix", + "systems": [ + "systems" + ], + "treefmt-nix": [ + "systems" + ] + }, + "locked": { + "lastModified": 1733814332, + "narHash": "sha256-7N2Y1m9qvKhpVGXOpCaVhhl/Ip3z6VfRPIdAQrKogaY=", + "ref": "refs/heads/main", + "rev": "8d505f6ee5bec721693106e57c32b9e31a7a3dfd", + "revCount": 5110, + "type": "git", + "url": "https://git.clan.lol/clan/clan-core" + }, + "original": { + "type": "git", + "url": "https://git.clan.lol/clan/clan-core" + } + }, "disko": { "inputs": { "nixpkgs": [ @@ -439,6 +473,21 @@ "type": "github" } }, + "nixos-facter-modules": { + "locked": { + "lastModified": 1732288619, + "narHash": "sha256-zSQ2cR+NRJfHUVfkv+O6Wi53wXfzX8KHiO8fRfnvc0M=", + "owner": "numtide", + "repo": "nixos-facter-modules", + "rev": "862648589993a96480c2255197a28feea712f68f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nixos-facter-modules", + "type": "github" + } + }, "nixos-images": { "inputs": { "nixos-stable": [ @@ -483,6 +532,7 @@ "root": { "inputs": { "agenix": "agenix", + "clan-core": "clan-core", "disko": "disko", "firefox-addons-overlay": "firefox-addons-overlay", "flake-compat": "flake-compat", @@ -518,6 +568,27 @@ "type": "github" } }, + "sops-nix": { + "inputs": { + "nixpkgs": [ + "clan-core", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1733128155, + "narHash": "sha256-m6/qwJAJYcidGMEdLqjKzRIjapK4nUfMq7rDCTmZajc=", + "owner": "Mic92", + "repo": "sops-nix", + "rev": "c6134b6fff6bda95a1ac872a2a9d5f32e3c37856", + "type": "github" + }, + "original": { + "owner": "Mic92", + "repo": "sops-nix", + "type": "github" + } + }, "systems": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 7e15b8e..5095c6f 100644 --- a/flake.nix +++ b/flake.nix @@ -70,275 +70,34 @@ inputs.nix-index-database.url = "github:nix-community/nix-index-database"; inputs.nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; - outputs = inputs@{ self, nixpkgs, nix-darwin, home-manager, flake-utils-plus - , agenix, disko, impermanence, nix-index-database, flake-parts, git-hooks - , terranix, ... }: - - nixpkgs.lib.recursiveUpdate - - (let - inherit (builtins) attrNames hasAttr filter getAttr readDir; - inherit (nixpkgs.lib) - concatMap filterAttrs foldr getAttrFromPath hasSuffix mapAttrs' - mapAttrsToList nameValuePair optionalAttrs recursiveUpdate removeSuffix - unique; - - importFrom = path: filename: import (path + ("/" + filename)); - - importOverlay = filename: _: importFrom ./overlays filename; - regularOverlays = - filterAttrs (name: _: hasSuffix ".nix" name) (readDir ./overlays); - importedRegularOverlays = mapAttrsToList importOverlay regularOverlays; - - flakeOverlays = attrNames - (filterAttrs (_: type: type == "directory") (readDir ./overlays)); - importedFlakeOverlays = - map (name: getAttrFromPath [ "${name}-overlay" "overlay" ] inputs) - flakeOverlays; - - modules = mapAttrs' (filename: _: - nameValuePair (removeSuffix ".nix" filename) - (importFrom ./modules filename)) (readDir ./modules); - - modules' = modules; - - getModuleList = a: - let - imports = - if (modules.${a} ? imports) then modules.${a}.imports else [ ]; - in if (imports == [ ]) then - [ a ] - else - [ a ] ++ unique (concatMap getModuleList imports); - - mkConfigurations = configs: - foldr (recursiveUpdate) { } (map (mkConfiguration) configs); - mkConfiguration = { host, hostSuffix ? "", user, system - , nixos ? hasSuffix "linux" system, modules }: - let - pkgs = import nixpkgs { - inherit system; - config.allowUnfree = true; - overlays = importedRegularOverlays ++ importedFlakeOverlays; - }; - - pkgs' = import nixpkgs { - system = "x86_64-linux"; - inherit (pkgs) config overlays; - }; - - moduleList = unique (concatMap getModuleList ([ "base" ] ++ modules)); - modulesToImport = map (name: getAttr name modules') moduleList; - - hostname = "${host}${hostSuffix}"; - nixosModules = map (getAttr "nixosModule") - (filter (hasAttr "nixosModule") modulesToImport); - homeModules = map (getAttr "homeModule") - (filter (hasAttr "homeModule") modulesToImport); - darwinModules = map (getAttr "darwinModule") - (filter (hasAttr "darwinModule") modulesToImport); - home = [ - nix-index-database.hmModules.nix-index - impermanence.nixosModules.home-manager.impermanence - ./hosts/${host}/home.nix - ] ++ homeModules; - - configRevision = { - full = self.rev or self.dirtyRev or "dirty-inputs"; - short = self.shortRev or self.dirtyShortRev or "dirty-inputs"; - }; + inputs.clan-core.url = "git+https://git.clan.lol/clan/clan-core"; + inputs.clan-core.inputs.disko.follows = "disko"; + inputs.clan-core.inputs.flake-parts.follows = "flake-parts"; + inputs.clan-core.inputs.nixpkgs.follows = "nixpkgs"; + inputs.clan-core.inputs.systems.follows = "systems"; + # This causes a stack overflow when set to empty string + inputs.clan-core.inputs.treefmt-nix.follows = "systems"; - keys = import ./keys.nix; - - extraHomeManagerArgs = { - inherit inputs nixos configRevision keys moduleList; - }; - in { - # nix build ~/.config/home-manager#nixosConfigurations.phi-nixos.config.system.build.toplevel - # OR - # nixos-rebuild build --flake ~/.config/home-manager#phi-nixos - nixosConfigurations = optionalAttrs nixos { - ${hostname} = nixpkgs.lib.nixosSystem { - inherit system; - modules = [ - { nixpkgs = { inherit (pkgs) config overlays; }; } - flake-utils-plus.nixosModules.autoGenFromInputs - agenix.nixosModules.age - disko.nixosModules.disko - impermanence.nixosModules.impermanence - nix-index-database.nixosModules.nix-index - ./hosts/${host}/configuration.nix - ] ++ nixosModules ++ [ - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - - # `home-manager` uses `/etc/profiles/per-user/` instead of `~/.nix-profile` - # Required for `fonts.fontconfig.enable = true;` - home-manager.useUserPackages = true; - - home-manager.users.${user}.imports = home; - home-manager.extraSpecialArgs = extraHomeManagerArgs; - } - ]; - specialArgs = { - inherit inputs configRevision user host hostname keys; - }; - }; - }; + outputs = inputs@{ self, nixpkgs, nix-darwin, home-manager, flake-utils-plus + , agenix, disko, impermanence, nix-index-database, flake-parts, clan-core + , git-hooks, terranix, ... }: - # nix build ~/.config/home-manager#darwinConfigurations.chi.system - # OR - # darwin-rebuild build --flake ~/.config/home-manager#chi - darwinConfigurations = - optionalAttrs pkgs.stdenv.hostPlatform.isDarwin { - ${hostname} = nix-darwin.lib.darwinSystem { - inherit system pkgs inputs; - modules = [ - flake-utils-plus.darwinModules.autoGenFromInputs - agenix.darwinModules.age - nix-index-database.darwinModules.nix-index - ./hosts/${host}/darwin-configuration.nix - ] ++ darwinModules ++ [ - home-manager.darwinModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ clan-core.flakeModules.default git-hooks.flakeModule ]; + systems = import inputs.systems; - home-manager.users.${user}.imports = home; - home-manager.extraSpecialArgs = extraHomeManagerArgs; - } - ]; - specialArgs = { - inherit configRevision user host hostname keys; - }; - }; - }; + clan = { + meta.name = "Enzime"; - # nix build ~/.config/home-manager#homeConfigurations.enzime@phi-nixos.activationPackage - # OR - # home-manager build --flake ~/.config/home-manager#enzime@phi-nixos - homeConfigurations."${user}@${hostname}" = - home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = [({ - home.username = user; - home.homeDirectory = if pkgs.stdenv.hostPlatform.isDarwin then - "/Users/${user}" - else - "/home/${user}"; - })] ++ home; - extraSpecialArgs = extraHomeManagerArgs; - }; + pkgsForSystem = system: nixpkgs.legacyPackages.${system}; - terraformConfigurations = optionalAttrs - (builtins.pathExists ./hosts/${host}/terraform-configuration.nix) { - ${hostname} = terranix.lib.terranixConfiguration { - system = "x86_64-linux"; - modules = [ ./hosts/${host}/terraform-configuration.nix ]; - extraArgs = { inherit inputs hostname; }; - }; - }; + machines = builtins.mapAttrs (hostname: configuration: { + imports = configuration._module.args.modules; - packages.x86_64-linux = optionalAttrs - (builtins.pathExists ./hosts/${host}/terraform-configuration.nix) { - "${hostname}-apply" = pkgs'.writeShellApplication { - name = "${hostname}-apply"; - runtimeInputs = [ self.packages.x86_64-linux.terraform ]; - text = '' - if [[ -e config.tf.json ]]; then rm -f config.tf.json; fi - cp ${ - self.terraformConfigurations.${hostname} - } config.tf.json \ - && terraform init \ - && terraform apply - ''; - }; + config = { _module.args = configuration._module.specialArgs; }; + }) self.baseNixosConfigurations; + }; - "${hostname}-destroy" = pkgs'.writeShellApplication { - name = "${hostname}-destroy"; - runtimeInputs = [ self.packages.x86_64-linux.terraform ]; - text = '' - if [[ -e config.tf.json ]]; then rm -f config.tf.json; fi - cp ${ - self.terraformConfigurations.${hostname} - } config.tf.json \ - && terraform init \ - && terraform destroy - ''; - }; - }; - }; - in (mkConfigurations [ - { - host = "chi"; - user = "enzime"; - system = "aarch64-darwin"; - modules = - builtins.attrNames { inherit (modules) linux-builder personal; }; - } - { - host = "hermes"; - hostSuffix = "-macos"; - user = "enzime"; - system = "aarch64-darwin"; - modules = builtins.attrNames { - inherit (modules) android laptop linux-builder personal; - }; - } - { - host = "hermes"; - hostSuffix = "-nixos"; - user = "enzime"; - system = "aarch64-linux"; - modules = - builtins.attrNames { inherit (modules) laptop personal sway; }; - } - { - host = "phi"; - hostSuffix = "-nixos"; - user = "enzime"; - system = "x86_64-linux"; - modules = builtins.attrNames { - inherit (modules) - android bluetooth deluge nextcloud personal printers samba scanners - sway wireless virt-manager; - }; - } - { - host = "sigma"; - user = "enzime"; - system = "x86_64-linux"; - modules = builtins.attrNames { - inherit (modules) impermanence laptop personal sway; - }; - } - { - host = "echo"; - user = "enzime"; - system = "aarch64-darwin"; - modules = builtins.attrNames { - inherit (modules) github-runner graphical-minimal; - }; - } - { - host = "eris"; - user = "human"; - system = "x86_64-linux"; - modules = - builtins.attrNames { inherit (modules) deluge reflector vncserver; }; - } - { - host = "aether"; - user = "enzime"; - system = "aarch64-linux"; - modules = [ ]; - } - ])) - - (flake-parts.lib.mkFlake { inherit inputs; } { - imports = [ git-hooks.flakeModule ]; - systems = import inputs.systems; perSystem = { config, self', pkgs, lib, system, ... }: lib.mkMerge [ { @@ -353,7 +112,7 @@ pre-commit.settings = { src = ./.; - hooks.nixfmt.enable = true; + hooks.nixfmt-classic.enable = true; hooks.nil.enable = true; hooks.shellcheck.enable = true; @@ -366,10 +125,13 @@ }; }; + formatter = config.pre-commit.settings.hooks.nixfmt-classic.package; + devShells.default = pkgs.mkShell { buildInputs = (builtins.attrValues { inherit (home-manager.packages.${system}) home-manager; inherit (agenix.packages.${system}) agenix; + inherit (clan-core.packages.${system}) clan-core; inherit (self'.packages) terraform; }) ++ config.pre-commit.settings.enabledPackages; @@ -521,6 +283,270 @@ (deploy hostname configuration)) self.darwinConfigurations; } ]; - flake = { keys = import ./keys.nix; }; - }); + flake = (let + inherit (builtins) attrNames hasAttr filter getAttr readDir; + inherit (nixpkgs.lib) + concatMap filterAttrs foldr getAttrFromPath hasSuffix mapAttrs' + mapAttrsToList nameValuePair optionals optionalAttrs recursiveUpdate + removeSuffix unique; + + importFrom = path: filename: import (path + ("/" + filename)); + + importOverlay = filename: _: importFrom ./overlays filename; + regularOverlays = + filterAttrs (name: _: hasSuffix ".nix" name) (readDir ./overlays); + importedRegularOverlays = mapAttrsToList importOverlay regularOverlays; + + flakeOverlays = attrNames + (filterAttrs (_: type: type == "directory") (readDir ./overlays)); + importedFlakeOverlays = + map (name: getAttrFromPath [ "${name}-overlay" "overlay" ] inputs) + flakeOverlays; + + modules = mapAttrs' (filename: _: + nameValuePair (removeSuffix ".nix" filename) + (importFrom ./modules filename)) (readDir ./modules); + + modules' = modules; + + getModuleList = a: + let + imports = + if (modules.${a} ? imports) then modules.${a}.imports else [ ]; + in if (imports == [ ]) then + [ a ] + else + [ a ] ++ unique (concatMap getModuleList imports); + + mkConfigurations = configs: + foldr (recursiveUpdate) { } (map (mkConfiguration) configs); + mkConfiguration = { host, hostSuffix ? "", user, system + , nixos ? hasSuffix "linux" system, modules, clan ? false }: + let + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + overlays = importedRegularOverlays ++ importedFlakeOverlays; + }; + + pkgs' = import nixpkgs { + system = "x86_64-linux"; + inherit (pkgs) config overlays; + }; + + moduleList = unique (concatMap getModuleList + ([ "base" ] ++ modules ++ optionals clan [ "clan" ])); + modulesToImport = map (name: getAttr name modules') moduleList; + + hostname = "${host}${hostSuffix}"; + nixosModules = map (getAttr "nixosModule") + (filter (hasAttr "nixosModule") modulesToImport); + homeModules = map (getAttr "homeModule") + (filter (hasAttr "homeModule") modulesToImport); + darwinModules = map (getAttr "darwinModule") + (filter (hasAttr "darwinModule") modulesToImport); + home = [ + nix-index-database.hmModules.nix-index + impermanence.nixosModules.home-manager.impermanence + ./hosts/${host}/home.nix + ] ++ homeModules; + + configRevision = { + full = self.rev or self.dirtyRev or "dirty-inputs"; + short = self.shortRev or self.dirtyShortRev or "dirty-inputs"; + }; + + keys = import ./keys.nix; + + extraHomeManagerArgs = { + inherit inputs nixos configRevision keys moduleList; + }; + + nixosConfigurationsKey = + if clan then "baseNixosConfigurations" else "nixosConfigurations"; + in { + # nix build ~/.config/home-manager#nixosConfigurations.phi-nixos.config.system.build.toplevel + # OR + # nixos-rebuild build --flake ~/.config/home-manager#phi-nixos + ${nixosConfigurationsKey} = optionalAttrs nixos { + ${hostname} = nixpkgs.lib.nixosSystem { + inherit system; + modules = [ + { nixpkgs = { inherit (pkgs) config overlays; }; } + flake-utils-plus.nixosModules.autoGenFromInputs + agenix.nixosModules.age + disko.nixosModules.disko + impermanence.nixosModules.impermanence + nix-index-database.nixosModules.nix-index + ./hosts/${host}/configuration.nix + ] ++ nixosModules ++ [ + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + + # `home-manager` uses `/etc/profiles/per-user/` instead of `~/.nix-profile` + # Required for `fonts.fontconfig.enable = true;` + home-manager.useUserPackages = true; + + home-manager.users.${user}.imports = home; + home-manager.extraSpecialArgs = extraHomeManagerArgs; + } + ]; + specialArgs = { + inherit inputs configRevision user host hostname keys; + }; + }; + }; + + # nix build ~/.config/home-manager#darwinConfigurations.chi.system + # OR + # darwin-rebuild build --flake ~/.config/home-manager#chi + darwinConfigurations = + optionalAttrs pkgs.stdenv.hostPlatform.isDarwin { + ${hostname} = nix-darwin.lib.darwinSystem { + inherit system pkgs inputs; + modules = [ + flake-utils-plus.darwinModules.autoGenFromInputs + agenix.darwinModules.age + nix-index-database.darwinModules.nix-index + ./hosts/${host}/darwin-configuration.nix + ] ++ darwinModules ++ [ + home-manager.darwinModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + + home-manager.users.${user}.imports = home; + home-manager.extraSpecialArgs = extraHomeManagerArgs; + } + ]; + specialArgs = { + inherit configRevision user host hostname keys; + }; + }; + }; + + # nix build ~/.config/home-manager#homeConfigurations.enzime@phi-nixos.activationPackage + # OR + # home-manager build --flake ~/.config/home-manager#enzime@phi-nixos + homeConfigurations."${user}@${hostname}" = + home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [({ + home.username = user; + home.homeDirectory = if pkgs.stdenv.hostPlatform.isDarwin then + "/Users/${user}" + else + "/home/${user}"; + })] ++ home; + extraSpecialArgs = extraHomeManagerArgs; + }; + + terraformConfigurations = optionalAttrs (builtins.pathExists + ./hosts/${host}/terraform-configuration.nix) { + ${hostname} = terranix.lib.terranixConfiguration { + system = "x86_64-linux"; + modules = [ ./hosts/${host}/terraform-configuration.nix ]; + extraArgs = { inherit inputs hostname; }; + }; + }; + + packages.x86_64-linux = optionalAttrs (builtins.pathExists + ./hosts/${host}/terraform-configuration.nix) { + "${hostname}-apply" = pkgs'.writeShellApplication { + name = "${hostname}-apply"; + runtimeInputs = [ self.packages.x86_64-linux.terraform ]; + text = '' + if [[ -e config.tf.json ]]; then rm -f config.tf.json; fi + cp ${ + self.terraformConfigurations.${hostname} + } config.tf.json \ + && terraform init \ + && terraform apply + ''; + }; + + "${hostname}-destroy" = pkgs'.writeShellApplication { + name = "${hostname}-destroy"; + runtimeInputs = [ self.packages.x86_64-linux.terraform ]; + text = '' + if [[ -e config.tf.json ]]; then rm -f config.tf.json; fi + cp ${ + self.terraformConfigurations.${hostname} + } config.tf.json \ + && terraform init \ + && terraform destroy + ''; + }; + }; + }; + in (mkConfigurations [ + { + host = "chi"; + user = "enzime"; + system = "aarch64-darwin"; + modules = + builtins.attrNames { inherit (modules) linux-builder personal; }; + } + { + host = "hermes"; + hostSuffix = "-macos"; + user = "enzime"; + system = "aarch64-darwin"; + modules = builtins.attrNames { + inherit (modules) android laptop linux-builder personal; + }; + } + { + host = "hermes"; + hostSuffix = "-nixos"; + user = "enzime"; + system = "aarch64-linux"; + modules = + builtins.attrNames { inherit (modules) laptop personal sway; }; + } + { + host = "phi"; + hostSuffix = "-nixos"; + user = "enzime"; + system = "x86_64-linux"; + modules = builtins.attrNames { + inherit (modules) + android bluetooth deluge nextcloud personal printers samba + scanners sway wireless virt-manager; + }; + } + { + host = "sigma"; + user = "enzime"; + system = "x86_64-linux"; + clan = true; + modules = builtins.attrNames { + inherit (modules) impermanence laptop personal sway; + }; + } + { + host = "echo"; + user = "enzime"; + system = "aarch64-darwin"; + modules = builtins.attrNames { + inherit (modules) github-runner graphical-minimal; + }; + } + { + host = "eris"; + user = "human"; + system = "x86_64-linux"; + modules = builtins.attrNames { + inherit (modules) deluge reflector vncserver; + }; + } + { + host = "aether"; + user = "enzime"; + system = "aarch64-linux"; + modules = [ ]; + } + ])); + }; } diff --git a/hosts/sigma/hardware-configuration.nix b/hosts/sigma/hardware-configuration.nix index 56ce37e..92fbc85 100644 --- a/hosts/sigma/hardware-configuration.nix +++ b/hosts/sigma/hardware-configuration.nix @@ -1,4 +1,4 @@ -{ config, ... }: +{ config, lib, ... }: { boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" ]; @@ -85,4 +85,6 @@ ExecStart = [ "${config.boot.zfs.package}/sbin/zfs mount -a -o remount" ]; }; }; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; } diff --git a/modules/base.nix b/modules/base.nix index 04ae3e2..afdad93 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -15,6 +15,7 @@ let }) ++ [ inputs.home-manager.packages.${pkgs.system}.default inputs.agenix.packages.${pkgs.system}.default + inputs.clan-core.packages.${pkgs.system}.default ]; users.users.root = { @@ -43,8 +44,9 @@ let type = "indirect"; }; - nix.settings.min-free = lib.mkDefault (3 * 1024 * 1024 * 1024); - nix.settings.max-free = lib.mkDefault (10 * 1024 * 1024 * 1024); + # Override Clan's default using mkDefault (1000) + nix.settings.min-free = lib.mkOverride 500 (3 * 1024 * 1024 * 1024); + nix.settings.max-free = lib.mkOverride 500 (10 * 1024 * 1024 * 1024); nix.settings.builders-use-substitutes = true; diff --git a/modules/clan.nix b/modules/clan.nix new file mode 100644 index 0000000..1c65771 --- /dev/null +++ b/modules/clan.nix @@ -0,0 +1,7 @@ +{ + nixosModule = { options, inputs, host, hostname, pkgs, lib, ... }: { + config = lib.optionalAttrs (options ? clan) { + clan.core.networking.targetHost = "root@${host}"; + }; + }; +} diff --git a/modules/flakes.nix b/modules/flakes.nix index c601492..edec14a 100644 --- a/modules/flakes.nix +++ b/modules/flakes.nix @@ -2,7 +2,7 @@ let shared = { config, pkgs, lib, ... }: { nix.package = lib.mkDefault pkgs.nix; # a < b | a == b - nix.settings.experimental-features = "nix-command flakes"; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; nix.settings.warn-dirty = false; }; in {