summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--flake.nix301
1 files changed, 116 insertions, 185 deletions
diff --git a/flake.nix b/flake.nix
index 1a20e9e..58d830c 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,197 +1,128 @@
{
inputs = {
- flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
- };
+ unstable.url = "github:nixos/nixpkgs/nixos-unstable";
- outputs = {
- self,
- nixpkgs,
- flake-utils,
- }: let
- mapOverlayOverride = namespace: overlay: final: prev: let
- overlayPkgs = overlay final prev;
- in
- {
- "${namespace}" = builtins.removeAttrs overlayPkgs ["override"];
- }
- // (overlayPkgs.override or {});
- in
- flake-utils.lib.eachDefaultSystem (system: {
- formatter = (import nixpkgs {inherit system;}).alejandra;
-
- packages =
- (import nixpkgs {
- inherit system;
- overlays = [(mapOverlayOverride "local" (import ./pkgs))];
- }).local;
- })
- // {
- templates = let
- system-flake = {
- path = ./templates/system-flake;
- description = "Opinionated flake for a NixOS system with Home Manager";
- };
- in {
- inherit system-flake;
-
- default = system-flake;
+ home-manager = {
+ url = "github:nix-community/home-manager/release-25.05";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+
+ nur.url = "github:nix-community/NUR";
+ impermanence.url = "github:nix-community/impermanence";
+ hm-isolation.url = "github:3442/hm-isolation";
+
+ nixvirt = {
+ url = "github:AshleyYakeley/NixVirt";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+
+ flake-utils.url = "github:numtide/flake-utils";
+
+ lanzaboote = {
+ url = "github:nix-community/lanzaboote";
+
+ inputs = {
+ nixpkgs.follows = "nixpkgs";
+ pre-commit-hooks-nix.follows = "";
+ };
+ };
+
+ trivionomicon = {
+ url = "git+https://git.posixlycorrect.com/deepState/trivionomicon?ref=master";
+ inputs = {
+ flake-utils.follows = "flake-utils";
+ nixpkgs.follows = "nixpkgs";
};
+ };
+
+ vpsadminos.url = "github:vpsfreecz/vpsadminos";
+ };
- overlays = let
- overlay = mapOverlayOverride "trivium" (import ./pkgs);
- in {
- default = overlay;
- trivium = overlay;
+ outputs =
+ flakes@{ self
+ , nixpkgs
+ , unstable
+ , home-manager
+ , nur
+ , impermanence
+ , hm-isolation
+ , nixvirt
+ , flake-utils
+ , lanzaboote
+ , trivionomicon
+ , vpsadminos
+ }:
+ let
+ system = "x86_64-linux";
+
+ pkgs = importPkgs nixpkgs;
+
+ importPkgs = flake: import flake {
+ inherit system;
+
+ config = import ./pkgs/config nixpkgs.lib;
+ overlays = [ nur.overlays.default trivionomicon.overlays.default self.overlays.default ];
};
- homeManagerModules.default = ./modules;
- nixosModules.default = ./modules;
-
- lib = {
- mkSystemFlake = {
- flakes,
- system,
- formatter ? "alejandra",
- localOverlayPath ? /. + "${flakes.self}" + /pkgs,
- nixpkgsConfigPath ? localOverlayPath + /config,
- nixosSourcePath ? /. + "${flakes.self}" + /sys,
- nixosPlatformsPath ?
- if nixosSourcePath != null
- then nixosSourcePath + /platform
- else null,
- hmSourcePath ? /. + "${flakes.self}" + /home,
- hmPlatformsPath ?
- if hmSourcePath != null
- then hmSourcePath + /platform
- else null,
- }: let
- optionalFlake = name:
- if flakes ? "${name}"
- then flakes.${name}
- else null;
-
- requireFlake = name:
- if flakes ? "${name}"
- then flakes.${name}
- else throw "Required flake input '${name}' is required but was not provided";
-
- nur = optionalFlake "nur";
- nixpkgs = requireFlake "nixpkgs";
- unstable = optionalFlake "unstable";
-
- home-manager =
- if hmSourcePath != null
- then requireFlake "home-manager"
- else null;
-
- pkgs = importPkgs nixpkgs;
-
- importPkgs = flake:
- import flake ({
- inherit system;
-
- config = import ./pkgs/config nixpkgs.lib;
- overlays = let
- conditions = [
- {
- overlay = nur.overlays.default;
- condition = nur != null;
- }
- # NB: Preserve the relative order
- {
- overlay = self.overlays.trivium;
- condition = true;
- }
- {
- overlay = flakes.self.overlays.default;
- condition = true;
- }
- ];
- in
- builtins.map (cond: cond.overlay) (builtins.filter (cond: cond.condition) conditions);
- }
- // (
- if nixpkgsConfigPath != null
- then {
- config = import nixpkgsConfigPath {inherit (nixpkgs) lib;};
- }
- else {}
- ));
-
- inherit (pkgs.trivium.lib) importAll;
+ inherit (pkgs.local.lib) importAll;
+
+ local = import ./pkgs;
+ in
+ with pkgs.lib; {
+ formatter.${system} = pkgs.nixpkgs-fmt;
+ packages.${system} = pkgs.local;
+
+ overlays.default = final: prev:
+ let
+ locals = local final prev;
in
- with pkgs.lib;
- {
- formatter.${system} =
- if formatter == "alejandra"
- then pkgs.alejandra
- else if formatter == "nixpkgs-fmt"
- then pkgs.nixpkgs-fmt
- else throw "Unknown formatter: '${formatter}'";
-
- packages.${system} = pkgs.local;
-
- overlays.default = final: prev: let
- overlay =
- if localOverlayPath != null
- then import localOverlayPath
- else (final: prev: {});
- in
- mapOverlayOverride "local" overlay final prev
- // optionalAttrs (unstable != null) {
- unstable = importPkgs unstable;
- };
- }
- // optionalAttrs (nixosSourcePath != null) {
- nixosConfigurations = let
- nixosSystem = {modules}:
- makeOverridable nixpkgs.lib.nixosSystem {
- inherit modules pkgs system;
-
- specialArgs = {
- inherit flakes;
- };
- };
-
- hostConfig = platform:
- nixosSystem {
- modules = [
- self.nixosModules.default
- nixosSourcePath
- platform
- ];
- };
- in
- mapAttrs (_: hostConfig) (importAll {root = nixosPlatformsPath;});
- }
- // optionalAttrs (hmSourcePath != null) {
- homeConfigurations = let
- registry = {...}: {
- config.nix.registry =
- mapAttrs
- (_: value: {flake = value;})
- flakes;
- };
-
- home = name: platform:
- home-manager.lib.homeManagerConfiguration {
- inherit pkgs;
-
- extraSpecialArgs = {
- inherit flakes;
- };
-
- modules = [
- self.homeManagerModules.default
- hmSourcePath
- platform
- registry
- ];
- };
- in
- mapAttrs home (importAll {root = hmPlatformsPath;});
+ {
+ local = locals;
+ unstable = importPkgs unstable;
+ } // locals.override;
+
+ nixosConfigurations =
+ let
+ nixosSystem = { modules }: makeOverridable nixpkgs.lib.nixosSystem {
+ inherit modules pkgs system;
+
+ specialArgs = {
+ inherit flakes;
};
- };
+ };
+
+ hostConfig = host: nixosSystem {
+ modules = [
+ ./sys
+ host
+ ];
+ };
+ in
+ mapAttrs (_: hostConfig) (importAll { root = ./sys/platform; });
+
+ homeConfigurations =
+ let
+ registry = { ... }: {
+ config.nix.registry = mapAttrs
+ (_: value: { flake = value; })
+ flakes;
+ };
+
+ home = name: platform: home-manager.lib.homeManagerConfiguration {
+ inherit pkgs;
+
+ extraSpecialArgs = {
+ inherit flakes;
+ };
+
+ modules = [
+ ./home
+ platform
+ registry
+ ];
+ };
+ in
+ mapAttrs home (importAll { root = ./home/platform; });
};
}