Commit 321a75767c89

Vincent Demeester <vincent@sbr.pm>
2025-04-15 23:25:51
Preparing kyushu and a major overall of the configuration
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 0b7ac86
lib/default.nix
@@ -38,7 +38,7 @@
     , system ? "x86_64-linux"
     , pkgsInput ? inputs.nixpkgs
     , homeInput ? inputs.home-manager
-    , ,
+    ,
     }:
     pkgsInput.lib.nixosSystem {
       specialArgs = {
@@ -57,7 +57,7 @@
         inputs.agenix.nixosModules.default
         # inputs.lanzaboote.nixosModules.lanzaboote
         homeInput.nixosModules.home-manager
-        ../host
+        ../systems
       ];
     };
 
@@ -78,4 +78,4 @@
         }
       ];
     };
-};
+}
nix/overlays/default.nix
@@ -1,4 +1,40 @@
+{ inputs, ... }:
 {
+  # FIXME: migrate to pkgs and overlays on root
+  additions = final: _prev: import ../../pkgs { pkgs = final; };
+  modifications = _final: prev: {
+    # example = prev.example.overrideAttrs (oldAttrs: rec {
+    # ...
+    # });
+    # custom-caddy = import ./custom-caddy.nix { pkgs = prev; };
+  };
+
+  # When applied, the unstable nixpkgs set (declared in the flake inputs) will
+  # be accessible through 'pkgs.unstable'
+  unstable-packages = final: _prev: {
+    master = import inputs.master {
+      inherit (final) system;
+      config.allowUnfree = true;
+      overlays = [
+        (_final: _prev: {
+          # example = prev.example.overrideAttrs (oldAttrs: rec {
+          # ...
+          # });
+        })
+      ];
+    };
+    unstable = import inputs.unstable {
+      inherit (final) system;
+      config.allowUnfree = true;
+      overlays = [
+        (_final: _prev: {
+          # example = prev.example.overrideAttrs (oldAttrs: rec {
+          # ...
+          # });
+        })
+      ];
+    };
+  };
   tekton = final: prev: {
 
     inherit (prev.callPackage ../packages/tkn { })
pkgs/default.nix
@@ -0,0 +1,10 @@
+# Custom packages, that can be defined similarly to ones from nixpkgs
+# Build them using 'nix build .#example' or (legacy) 'nix-build -A example'
+
+{ pkgs ? (import ../nixpkgs.nix) { }
+,
+}:
+{
+  # TODO: migrate things from nix/packages
+  nixfmt-plus = pkgs.callPackage ./nixfmt-plus.nix { };
+}
pkgs/nixfmt-plus.nix
@@ -0,0 +1,16 @@
+{ pkgs, ... }:
+
+pkgs.writeShellApplication {
+  name = "nixfmt-plus";
+  runtimeInputs = with pkgs; [
+    deadnix
+    nixfmt-rfc-style
+    statix
+  ];
+  text = ''
+    set -x
+    deadnix --edit
+    statix fix
+    nixfmt .
+  '';
+}
systems/default.nix
@@ -0,0 +1,95 @@
+{ config
+, desktop
+, hostname
+, inputs
+, lib
+, modulesPath
+, outputs
+, stateVersion
+, ...
+}:
+{
+
+  imports = [
+    (./. + "/${hostname}/boot.nix")
+    (./. + "/${hostname}/hardware.nix")
+
+    ./common/base
+    # ./common/users/${username}
+  ]
+  ++ lib.optional (builtins.pathExists (./. + "/${hostname}/extra.nix")) ./${hostname}/extra.nix;
+
+  nixpkgs = {
+    overlays = [
+      # Our own flake exports (from overlays and pkgs dir)
+      outputs.overlays.additions
+      outputs.overlays.modifications
+      outputs.overlays.unstable-packages
+
+      # And from other flakes
+      inputs.emacs-overlay.overlay
+      inputs.chapeau-rouge.overlays.openshift
+      inputs.chick-group.overlays.default
+      inputs.agenix.overlays.default
+
+      # Migrate to "modifications"
+      (_: prev: {
+        inherit (inputs.buildkit-tekton.packages.${prev.system}) tkn-local;
+        inherit (inputs.dagger.packages.${prev.system}) dagger;
+      })
+    ];
+    config = {
+      allowUnfree = true;
+    };
+  };
+
+  nix = {
+    # This will add each flake input as a registry
+    # To make nix3 commands consistent with your flake
+    registry = lib.mkForce (lib.mapAttrs (_: value: { flake = value; }) inputs);
+
+    # This will additionally add your inputs to the system's legacy channels
+    # Making legacy nix commands consistent as well, awesome!
+    nixPath = lib.mkForce (
+      lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry
+    );
+
+    optimise = {
+      automatic = true;
+      dates = [ "01:10" "12:10" ];
+    };
+
+    settings = {
+      auto-optimise-store = true;
+      experimental-features = [
+        "nix-command"
+        "flakes"
+      ];
+      sandbox = true;
+      allowed-users = [
+        "@wheel"
+      ];
+      trusted-users = [
+        "root"
+        "@wheel"
+      ];
+      # See https://nixos.org/manual/nix/stable/command-ref/conf-file#conf-use-xdg-base-directories
+      use-xdg-base-directories = true;
+      extraOptions = ''
+        connect-timeout = 20
+        build-cores = 0
+        keep-outputs = true
+        keep-derivations = true
+        builders-use-substitutes = true
+      '';
+    };
+  };
+
+  # `nix-daemon` will hit the stack limit when using `nixFlakes`.
+  systemd.services.nix-daemon.serviceConfig."LimitSTACK" = "infinity";
+
+  system = {
+    inherit stateVersion;
+  };
+
+}
flake.nix
@@ -175,7 +175,7 @@
       # This is probably not gonna happen, instead I should move any internal package here outside, in their
       # own repository and flake. If they are useful upstream.
 
-      overlays = import ./nix/overlays;
+      overlays = import ./nix/overlays { inherit inputs; };
 
       devShells.x86_64-linux.default =
         let