about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--flake.nix111
-rw-r--r--flake/apps/default.nix23
-rw-r--r--flake/default.nix120
-rw-r--r--flake/nixosConfigurations/default.nix108
-rw-r--r--flake/packages/default.nix40
5 files changed, 239 insertions, 163 deletions
diff --git a/flake.nix b/flake.nix
index 1925b1db..0c4167d5 100644
--- a/flake.nix
+++ b/flake.nix
@@ -3,13 +3,8 @@
   description = "Nixos system config";
 
   inputs = {
+    # base
     nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
-    home-manager = {
-      url = "github:nix-community/home-manager/master";
-      inputs = {
-        nixpkgs.follows = "nixpkgs";
-      };
-    };
 
     # inputs for following
     systems = {
@@ -28,14 +23,12 @@
         rust-overlay.follows = "rust-overlay";
       };
     };
-
     flake-utils = {
       url = "github:numtide/flake-utils";
       inputs = {
         systems.follows = "systems";
       };
     };
-
     rust-overlay = {
       url = "github:oxalica/rust-overlay";
       inputs = {
@@ -44,6 +37,13 @@
       };
     };
 
+    # nixos modules
+    home-manager = {
+      url = "github:nix-community/home-manager/master";
+      inputs = {
+        nixpkgs.follows = "nixpkgs";
+      };
+    };
     agenix = {
       url = "github:ryantm/agenix";
       inputs = {
@@ -65,7 +65,12 @@
       inputs = {
       };
     };
+    nixos-generators = {
+      url = "github:nix-community/nixos-generators";
+      inputs.nixpkgs.follows = "nixpkgs";
+    };
 
+    # my configs
     neovim_config = {
       url = "git+https://codeberg.org/soispha/neovim-config.git";
       flake = false;
@@ -76,6 +81,7 @@
       };
     };
 
+    # my bins
     grades = {
       url = "git+https://codeberg.org/ene/Grades.git";
       inputs = {
@@ -130,6 +136,7 @@
       };
     };
 
+    # external resources
     user_js = {
       url = "github:arkenfox/user.js";
       flake = false;
@@ -144,8 +151,9 @@
     # core
     self,
     nixpkgs,
-    home-manager,
     # modules
+    home-manager,
+    nixos-generators,
     impermanence,
     agenix,
     ragenix,
@@ -170,79 +178,38 @@
       inherit (nixpkgs) lib;
       inherit system;
     });
-  in {
-    nixosConfigurations = import ./flake/nixosConfigurations {
+    outputs = import ./flake {
       inherit
-        system
+        # core
+        self
         pkgs
-        nixpkgs
+        system
         sysLib
+        nixpkgs
+        # modules
+        
         home-manager
-        agenix
+        nixos-generators
         impermanence
+        agenix
+        ragenix
+        # external dependencies
+        
+        neovim_config
+        user_js
+        snap-sync
         templates
+        # my binaries
+        
+        video_pause
+        strip_js_comments
+        shell-library
         river_init_lesser
         yambar_memory
         yambar_cpu
-        video_pause
         grades
-        neovim_config
-        strip_js_comments
-        shell-library
-        user_js
-        snap-sync
         ;
     };
-    packages."${system}" = {
-      install = import ./bootstrap/install {
-        inherit
-          pkgs
-          shell-library
-          ;
-      };
-      activate = import ./bootstrap/activate {
-        inherit
-          pkgs
-          shell-library
-          ;
-      };
-      setup = import ./bootstrap/setup {
-        inherit
-          pkgs
-          shell-library
-          ;
-      };
-      config_setup = import ./bootstrap/config_setup {
-        inherit
-          pkgs
-          shell-library
-          ;
-      };
-    };
-
-    apps."${system}" = {
-      install = {
-        type = "app";
-        program = "${self.packages."${system}".install}/bin/install";
-      };
-      activate = {
-        type = "app";
-        program = "${self.packages."${system}".activate}/bin/activate";
-      };
-      setup = {
-        type = "app";
-        program = "${self.packages."${system}".setup}/bin/setup";
-      };
-      config_setup = {
-        type = "app";
-        program = "${self.packages."${system}".config_setup}/bin/config_setup";
-      };
-      default = self.apps."${system}".activate;
-    };
-    devShells."${system}" = {
-      default = pkgs.mkShell {
-        packages = with pkgs; [nil alejandra statix ragenix.packages."${system}".default shellcheck ltex-ls];
-      };
-    };
-  };
+  in
+    outputs;
 }
diff --git a/flake/apps/default.nix b/flake/apps/default.nix
new file mode 100644
index 00000000..f1709c71
--- /dev/null
+++ b/flake/apps/default.nix
@@ -0,0 +1,23 @@
+{
+  self,
+  system,
+  ...
+}: {
+  install = {
+    type = "app";
+    program = "${self.packages."${system}".install}/bin/install";
+  };
+  activate = {
+    type = "app";
+    program = "${self.packages."${system}".activate}/bin/activate";
+  };
+  setup = {
+    type = "app";
+    program = "${self.packages."${system}".setup}/bin/setup";
+  };
+  config_setup = {
+    type = "app";
+    program = "${self.packages."${system}".config_setup}/bin/config_setup";
+  };
+  default = self.apps."${system}".activate;
+}
diff --git a/flake/default.nix b/flake/default.nix
new file mode 100644
index 00000000..c88bfe56
--- /dev/null
+++ b/flake/default.nix
@@ -0,0 +1,120 @@
+{
+  # core
+  self,
+  pkgs,
+  system,
+  sysLib,
+  nixpkgs,
+  # modules
+  home-manager,
+  nixos-generators,
+  impermanence,
+  agenix,
+  ragenix,
+  # external dependencies
+  neovim_config,
+  user_js,
+  snap-sync,
+  templates,
+  # my binaries
+  video_pause,
+  strip_js_comments,
+  shell-library,
+  river_init_lesser,
+  yambar_memory,
+  yambar_cpu,
+  grades,
+}: let
+  homeManagerConfig = {
+    home-manager = {
+      useGlobalPkgs = true;
+      useUserPackages = true;
+      users.soispha = import ../home-manager;
+      extraSpecialArgs = {
+        inherit
+          pkgs
+          sysLib
+          # extra information
+          
+          system
+          # bins
+          
+          video_pause
+          yambar_cpu
+          yambar_memory
+          strip_js_comments
+          river_init_lesser
+          grades
+          shell-library
+          # external deps
+          
+          user_js
+          neovim_config
+          snap-sync
+          # modules
+          
+          impermanence
+          ;
+      };
+    };
+  };
+  ageConfig = import ../secrets;
+  impermanenceConfig = import ../system/impermanence;
+  defaultModules = [
+    agenix.nixosModules.default
+    ageConfig
+
+    home-manager.nixosModules.home-manager
+
+    homeManagerConfig
+
+    impermanence.nixosModules.impermanence
+    impermanenceConfig
+  ];
+  defaultSpecialArgs = {
+    nixpkgs-as-input = nixpkgs;
+    inherit templates sysLib;
+  };
+in {
+  nixosConfigurations = import ./nixosConfigurations {
+    inherit
+      system
+      pkgs
+      nixpkgs
+      sysLib
+      # configs
+      
+      defaultModules
+      defaultSpecialArgs
+      # bins
+      
+      video_pause
+      yambar_cpu
+      yambar_memory
+      strip_js_comments
+      river_init_lesser
+      grades
+      shell-library
+      # external deps
+      
+      user_js
+      neovim_config
+      snap-sync
+      templates
+      # modules
+      
+      impermanence
+      home-manager
+      agenix
+      ;
+  };
+  packages."${system}" = import ./packages {inherit nixos-generators defaultSpecialArgs pkgs shell-library;};
+
+  apps."${system}" = import ./apps {inherit self system;};
+
+  devShells."${system}" = {
+    default = pkgs.mkShell {
+      packages = with pkgs; [nil alejandra statix ragenix.packages."${system}".default shellcheck ltex-ls];
+    };
+  };
+}
diff --git a/flake/nixosConfigurations/default.nix b/flake/nixosConfigurations/default.nix
index 173882b7..0698da76 100644
--- a/flake/nixosConfigurations/default.nix
+++ b/flake/nixosConfigurations/default.nix
@@ -4,6 +4,9 @@
   pkgs,
   nixpkgs,
   sysLib,
+  # configs
+  defaultModules,
+  defaultSpecialArgs,
   # bins
   video_pause,
   yambar_cpu,
@@ -23,96 +26,19 @@
   agenix,
   ...
 }: let
-  homeManagerConfig = {
-    home-manager = {
-      useGlobalPkgs = true;
-      useUserPackages = true;
-      users.soispha = import ../../home-manager;
-      extraSpecialArgs = {
-        inherit
-          pkgs
-          sysLib
-          # extra information
-          
-          system
-          # bins
-          
-          video_pause
-          yambar_cpu
-          yambar_memory
-          strip_js_comments
-          river_init_lesser
-          grades
-          shell-library
-          # external deps
-          
-          user_js
-          neovim_config
-          snap-sync
-          # modules
-          
-          impermanence
-          ;
-      };
+  generateHost = name: {
+    name = "${name}";
+    value = nixpkgs.lib.nixosSystem {
+      inherit system pkgs;
+      specialArgs = defaultSpecialArgs;
+      modules =
+        [
+          ../../hosts/${name}
+        ]
+        ++ defaultModules;
     };
   };
-  ageConfig = import ../../secrets;
-  impermanenceConfig = import ../../system/impermanence;
-  defaultModules = [
-    agenix.nixosModules.default
-    ageConfig
-
-    home-manager.nixosModules.home-manager
-
-    homeManagerConfig
-
-    impermanence.nixosModules.impermanence
-    impermanenceConfig
-  ];
-  defaultSpecialArgs = {
-    nixpkgs-as-input = nixpkgs;
-    inherit templates sysLib;
-  };
-in {
-  tiamat = nixpkgs.lib.nixosSystem {
-    inherit system pkgs;
-    specialArgs = defaultSpecialArgs;
-    modules =
-      [
-        ../../hosts/tiamat/configuration.nix
-      ]
-      ++ defaultModules;
-  };
-
-  mammun = nixpkgs.lib.nixosSystem {
-    inherit system pkgs;
-    specialArgs = defaultSpecialArgs;
-    modules =
-      [
-        ../../hosts/mammun/configuration.nix
-      ]
-      ++ defaultModules;
-  };
-  lahmu = nixpkgs.lib.nixosSystem {
-    inherit system pkgs;
-    specialArgs = defaultSpecialArgs;
-    modules =
-      [
-        ../../hosts/lahmu/configuration.nix
-      ]
-      ++ defaultModules;
-  };
-  apzu = nixpkgs.lib.nixosSystem {
-    inherit system pkgs;
-    specialArgs = defaultSpecialArgs;
-    modules =
-      [
-        ../../hosts/apzu/configuration.nix
-      ]
-      ++ defaultModules;
-  };
-  spawn = nixpkgs.lib.nixosSystem {
-    specialArgs = defaultSpecialArgs;
-    modules = [../../hosts/spawn/configuration.nix];
-  };
-}
+  hosts = ["tiamat" "mammun" "apzu" "lahmu"];
+  generatedHosts = builtins.listToAttrs (builtins.map generateHost hosts);
+in
+  generatedHosts
diff --git a/flake/packages/default.nix b/flake/packages/default.nix
new file mode 100644
index 00000000..470ea05c
--- /dev/null
+++ b/flake/packages/default.nix
@@ -0,0 +1,40 @@
+{
+  nixos-generators,
+  defaultSpecialArgs,
+  pkgs,
+  shell-library,
+  ...
+}: {
+  iso = nixos-generators.nixosGenerate {
+    system = "x86_64-linux";
+    specialArgs = defaultSpecialArgs;
+    modules = [
+      ../../hosts/marduk
+    ];
+    format = "install-iso";
+  };
+  install = import ../../bootstrap/install {
+    inherit
+      pkgs
+      shell-library
+      ;
+  };
+  activate = import ../../bootstrap/activate {
+    inherit
+      pkgs
+      shell-library
+      ;
+  };
+  setup = import ../../bootstrap/setup {
+    inherit
+      pkgs
+      shell-library
+      ;
+  };
+  config_setup = import ../../bootstrap/config_setup {
+    inherit
+      pkgs
+      shell-library
+      ;
+  };
+}