about summary refs log tree commit diff stats
path: root/flake
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2023-04-22 12:07:54 +0200
committerSoispha <soispha@vhack.eu>2023-05-09 19:31:20 +0200
commit3fc2c8d0c8c4a3c839fc12abad94ca83f4d21870 (patch)
treec0172a350b9f4bb0e3448b3f20c228c1403dbe0d /flake
parentFix(hosts): Rename spawn to marduk to comply with scheme (diff)
downloadnixos-config-3fc2c8d0c8c4a3c839fc12abad94ca83f4d21870.tar.gz
nixos-config-3fc2c8d0c8c4a3c839fc12abad94ca83f4d21870.zip
Feat(flake): Modularize
Diffstat (limited to 'flake')
-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
4 files changed, 200 insertions, 91 deletions
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
+      ;
+  };
+}