aboutsummaryrefslogtreecommitdiff
path: root/nix/flake/hosts.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nix/flake/hosts.nix')
-rw-r--r--nix/flake/hosts.nix184
1 files changed, 0 insertions, 184 deletions
diff --git a/nix/flake/hosts.nix b/nix/flake/hosts.nix
deleted file mode 100644
index d3454bf..0000000
--- a/nix/flake/hosts.nix
+++ /dev/null
@@ -1,184 +0,0 @@
-{
- inputs,
- self,
- withSystem,
- ...
-}:
-let
- inherit (inputs.nixpkgs.lib // builtins)
- filterAttrs
- foldl'
- makeOverridable
- mapAttrs'
- mapAttrsToList
- mkForce
- mkIf
- nixosSystem
- readDir
- replaceStrings
- substring
- ;
-
- inherit (inputs.darwin.lib) darwinSystem;
-
- nixSettings = {
- nix.registry.nixpkgs = {
- flake = inputs.nixpkgs;
- };
- };
-
- mapSystems =
- dir: mapAttrsToList (name: _: name) (filterAttrs (_: type: type == "directory") (readDir dir));
-
- mapHosts = foldl' (
- hosts: system:
- hosts
- // (mapAttrs' (
- filename: _:
- let
- name = replaceStrings [ ".nix" ] [ "" ] filename;
- in
- {
- inherit name;
- value = {
- inherit system;
- hostconf = "${self}/machines/nixos/${system}/${filename}";
- };
- }
- ) (builtins.readDir "${self}/machines/nixos/${system}"))
- ) { };
-
- mapMacs = foldl' (
- hosts: system:
- hosts
- // (mapAttrs' (
- filename: _:
- let
- name = replaceStrings [ ".nix" ] [ "" ] filename;
- in
- {
- inherit name;
- value = {
- inherit system;
- hostconf = "${self}/machines/darwin/${system}/${filename}";
- };
- }
- ) (builtins.readDir "${self}/machines/darwin/${system}"))
- ) { };
-
- defaultModules = [
- nixSettings
- inputs.agenix.nixosModules.age
- inputs.disko.nixosModules.disko
- inputs.home-manager.nixosModules.home-manager
- "${self}/nix/modules/default.nix"
- ];
-
- darwinDefaultModules = [
- nixSettings
- inputs.agenix.darwinModules.age
- inputs.home-manager.darwinModules.home-manager
- "${self}/nix/modules/default-darwin.nix"
- ];
-
- darwinConfigurations = mapAttrs' (
- name: conf:
- let
- inherit (conf) system hostconf;
- adminUser = {
- name = "fcuny";
- userinfo = {
- email = "franck@fcuny.net";
- fullName = "Franck Cuny";
- };
- };
- in
- {
- inherit name;
- value = withSystem system (
- { pkgs, ... }:
- makeOverridable darwinSystem {
- inherit system;
- specialArgs = {
- hostName = name;
- inherit adminUser;
- inherit self;
- inherit inputs;
- };
- modules =
- [
- { inherit adminUser; }
- {
- nixpkgs.pkgs = pkgs;
- nixpkgs.hostPlatform = system;
- system.stateVersion = 5;
- environment.systemPackages = [
- pkgs.git
- ];
- }
- ]
- ++ darwinDefaultModules
- ++ [
- hostconf
- ];
- }
- );
- }
- ) (mapMacs (mapSystems "${self}/machines/darwin"));
-
- nixosConfigurations = mapAttrs' (
- name: conf:
- let
- inherit (conf) system hostconf;
- adminUser = {
- name = "fcuny";
- userinfo = {
- email = "franck@fcuny.net";
- fullName = "Franck Cuny";
- };
- };
- in
- {
- inherit name;
- value = withSystem system (
- { pkgs, ... }:
- makeOverridable nixosSystem {
- inherit system;
- specialArgs = {
- hostName = name;
- inherit adminUser;
- inherit self;
- hostConfigurations = mapAttrs' (name: conf: {
- inherit name;
- value = conf.config;
- }) nixosConfigurations;
- inherit inputs;
- };
- modules =
- [
- {
- inherit adminUser;
- }
- {
- system.configurationRevision = mkIf (self ? rev) self.rev;
- system.nixos.versionSuffix = mkForce "git.${substring 0 11 inputs.nixpkgs.rev}";
- nixpkgs.pkgs = pkgs;
- environment.systemPackages = [
- pkgs.git
- ];
- }
- ]
- ++ defaultModules
- ++ [
- hostconf
- ];
- }
- );
- }
- ) (mapHosts (mapSystems "${self}/machines/nixos"));
-in
-{
- flake = {
- inherit nixosConfigurations darwinConfigurations;
- };
-}