From 880b5b998842b609d14f3924b149b327e2924e88 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Sun, 8 Aug 2021 07:37:33 -0700 Subject: [PATCH 01/41] split hosts by nixos/darwin to accomodate new mode --- lib/system-flake.nix | 85 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 66 insertions(+), 19 deletions(-) diff --git a/lib/system-flake.nix b/lib/system-flake.nix index b3df746..f89a855 100644 --- a/lib/system-flake.nix +++ b/lib/system-flake.nix @@ -34,6 +34,9 @@ # NixOS specific modules. , extraNixosModules ? [ ] + # nix-darwin specific modules. +, extraNixDarwinModules ? [ ] + # The global extra arguments are included in both NixOS and home-manager. , globalSpecialArgs ? { } @@ -43,6 +46,9 @@ # NixOS specific extra arguments. , nixosSpecialArgs ? { } + # nix-darwin specific extra arguments. +, nixDarwinSpecialArgs ? { } + # Evaluates to `packages.. = .`. , packagesBuilder ? (_: { }) @@ -72,9 +78,11 @@ let "extraGlobalModules" "extraHomeManagerModules" "extraNixosModules" + "extraNixDarwinModules" "globalSpecialArgs" "hmSpecialArgs" "nixosSpecialArgs" + "nixDarwinSpecialArgs" "packagesBuilder" "sharedOverlays" ]; @@ -82,25 +90,62 @@ let # generate each host by injecting special arguments and the given host # without certain soxin-only attributes. hosts' = - mapAttrs - (hostname: host: (recursiveUpdate - { - specialArgs = { - inherit soxin soxincfg home-manager; - - # the mode allows us to tell at what level we are within the modules. - mode = "NixOS"; - } - # include the global special arguments. - // globalSpecialArgs - # include the NixOS special arguments. - // nixosSpecialArgs; - } - - # pass along the hosts minus the deploy key that's specific to soxin. - (removeAttrs host [ "deploy" ]) - )) - hosts; + let + # TODO: make this more generic + # hostOS = host: builtins.head (builtins.tail (builtins.split ".*-(linux|darwin)" host.system)); + # isDarwin = system: (lib.systems.parse.mkSystemFromString system) + isDarwin = host: host.system == "x86_64-darwin"; + isLinux = host: host.system == "x86_64-linux" || host.system == "aarch64-linux"; + + darwinHosts = + let + darwinOnlyHosts = filterAttrs (n: host: isDarwin host) hosts; + in + mapAttrs + (hostname: host: (recursiveUpdate + { + specialArgs = { + inherit soxin soxincfg home-manager; + + # the mode allows us to tell at what level we are within the modules. + mode = "nix-darwin"; + } + # include the global special arguments. + // globalSpecialArgs + # include the NixDarwin special arguments. + // nixDarwinSpecialArgs; + } + + # pass along the hosts minus the deploy key that's specific to soxin. + (removeAttrs host [ "deploy" ]) + )) + darwinOnlyHosts; + + nixosHosts = + let + nixosOnlyHosts = filterAttrs (n: host: isLinux host) hosts; + in + mapAttrs + (hostname: host: (recursiveUpdate + { + specialArgs = { + inherit soxin soxincfg home-manager; + + # the mode allows us to tell at what level we are within the modules. + mode = "NixOS"; + } + # include the global special arguments. + // globalSpecialArgs + # include the NixOS special arguments. + // nixosSpecialArgs; + } + + # pass along the hosts minus the deploy key that's specific to soxin. + (removeAttrs host [ "deploy" ]) + )) + nixosOnlyHosts; + in + darwinHosts // nixosHosts; # Generate the deployment nodes. deploy.nodes = @@ -219,6 +264,8 @@ let home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; + # TODO: Must wire up extraNixDarwinModules + home-manager.extraSpecialArgs = { inherit soxin soxincfg home-manager; From d8505498d4b0cf485a5fb90beec8606b261b26e0 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Sun, 8 Aug 2021 21:21:30 -0700 Subject: [PATCH 02/41] construct the hosts based on their mode --- lib/system-flake.nix | 143 +++++++++++++++++++++++++++---------------- 1 file changed, 89 insertions(+), 54 deletions(-) diff --git a/lib/system-flake.nix b/lib/system-flake.nix index f89a855..30723fd 100644 --- a/lib/system-flake.nix +++ b/lib/system-flake.nix @@ -91,29 +91,62 @@ let # without certain soxin-only attributes. hosts' = let - # TODO: make this more generic - # hostOS = host: builtins.head (builtins.tail (builtins.split ".*-(linux|darwin)" host.system)); - # isDarwin = system: (lib.systems.parse.mkSystemFromString system) - isDarwin = host: host.system == "x86_64-darwin"; - isLinux = host: host.system == "x86_64-linux" || host.system == "aarch64-linux"; - darwinHosts = let - darwinOnlyHosts = filterAttrs (n: host: isDarwin host) hosts; + darwinOnlyHosts = filterAttrs (n: host: host.mode == "nix-darwin") hosts; in mapAttrs (hostname: host: (recursiveUpdate { specialArgs = { inherit soxin soxincfg home-manager; - - # the mode allows us to tell at what level we are within the modules. - mode = "nix-darwin"; } # include the global special arguments. // globalSpecialArgs # include the NixDarwin special arguments. // nixDarwinSpecialArgs; + + modules = + [ ] + # include sops + # ++ (optionals withSops (singleton sops-nix.nixosModules.sops)) + # include sane flake defaults from flake-utils-plus which sets sane `nix.*` defaults. + # Please refer to implementation/readme in + # github:gytis-ivaskevicius/flake-utils-plus for more details. + # ++ (singleton flake-utils-plus.nixosModules.saneFlakeDefaults) + # include the nix-darwin modules + ++ extraNixDarwinModules + # include Soxin modules + ++ (singleton soxin.nixosModule) + # include home-manager modules + ++ (singleton home-manager.nixosModules.home-manager) + # configure home-manager + ++ (singleton { + # tell home-manager to use the global (as in NixOS system-level) pkgs and + # install all user packages through the users.users..packages. + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + + home-manager.extraSpecialArgs = { + inherit soxin soxincfg home-manager; + + # the mode allows us to tell at what level we are within the modules. + mode = "home-manager"; + } + # include the global special arguments. + // globalSpecialArgs + # include the home-manager special arguments. + // hmSpecialArgs; + + home-manager.sharedModules = + # include the global modules + extraGlobalModules + # include the home-manager modules + ++ extraHomeManagerModules + # include Soxin module + ++ (singleton soxin.nixosModule); + }) + ; } # pass along the hosts minus the deploy key that's specific to soxin. @@ -123,27 +156,68 @@ let nixosHosts = let - nixosOnlyHosts = filterAttrs (n: host: isLinux host) hosts; + nixosOnlyHosts = filterAttrs (n: host: host.mode == "NixOS") hosts; in mapAttrs (hostname: host: (recursiveUpdate { specialArgs = { inherit soxin soxincfg home-manager; - - # the mode allows us to tell at what level we are within the modules. - mode = "NixOS"; } # include the global special arguments. // globalSpecialArgs # include the NixOS special arguments. // nixosSpecialArgs; + + modules = + [ ] + # include sops + ++ (optionals withSops (singleton sops-nix.nixosModules.sops)) + # include sane flake defaults from flake-utils-plus which sets sane `nix.*` defaults. + # Please refer to implementation/readme in + # github:gytis-ivaskevicius/flake-utils-plus for more details. + ++ (singleton flake-utils-plus.nixosModules.saneFlakeDefaults) + # include the NixOS modules + ++ extraNixosModules + # include Soxin modules + ++ (singleton soxin.nixosModule) + # include home-manager modules + ++ (singleton home-manager.nixosModules.home-manager) + # configure home-manager + ++ (singleton { + # tell home-manager to use the global (as in NixOS system-level) pkgs and + # install all user packages through the users.users..packages. + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + + home-manager.extraSpecialArgs = { + inherit soxin soxincfg home-manager; + + # the mode allows us to tell at what level we are within the modules. + mode = "home-manager"; + } + # include the global special arguments. + // globalSpecialArgs + # include the home-manager special arguments. + // hmSpecialArgs; + + home-manager.sharedModules = + # include the global modules + extraGlobalModules + # include the home-manager modules + ++ extraHomeManagerModules + # include Soxin module + ++ (singleton soxin.nixosModule); + }) + ; } # pass along the hosts minus the deploy key that's specific to soxin. (removeAttrs host [ "deploy" ]) )) nixosOnlyHosts; + + # TODO: add support for home-manager modes in darwinHosts // nixosHosts; @@ -243,48 +317,9 @@ let modules = # include the modules that are passed in (hostDefaults.modules or [ ]) - # include sops - ++ (optionals withSops (singleton sops-nix.nixosModules.sops)) # include the global modules ++ extraGlobalModules - # include sane flake defaults from flake-utils-plus which sets sane `nix.*` defaults. - # Please refer to implementation/readme in - # github:gytis-ivaskevicius/flake-utils-plus for more details. - ++ (singleton flake-utils-plus.nixosModules.saneFlakeDefaults) - # include the NixOS modules - ++ extraNixosModules - # include Soxin modules - ++ (singleton soxin.nixosModule) - # include home-manager modules - ++ (singleton home-manager.nixosModules.home-manager) - # configure home-manager - ++ (singleton { - # tell home-manager to use the global (as in NixOS system-level) pkgs and - # install all user packages through the users.users..packages. - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - - # TODO: Must wire up extraNixDarwinModules - - home-manager.extraSpecialArgs = { - inherit soxin soxincfg home-manager; - - # the mode allows us to tell at what level we are within the modules. - mode = "home-manager"; - } - # include the global special arguments. - // globalSpecialArgs - # include the home-manager special arguments. - // hmSpecialArgs; - - home-manager.sharedModules = - # include the global modules - extraGlobalModules - # include the home-manager modules - ++ extraHomeManagerModules - # include Soxin module - ++ (singleton soxin.nixosModule); - }); + ; }; } // (optionalAttrs withDeploy { From 27f66d3c84664de5e0c94dbb2125de7d3f6d450e Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Sun, 8 Aug 2021 21:30:41 -0700 Subject: [PATCH 03/41] remove mode out of host attributes passed over to flake-utils-plus --- lib/system-flake.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/system-flake.nix b/lib/system-flake.nix index 30723fd..726059e 100644 --- a/lib/system-flake.nix +++ b/lib/system-flake.nix @@ -149,8 +149,8 @@ let ; } - # pass along the hosts minus the deploy key that's specific to soxin. - (removeAttrs host [ "deploy" ]) + # pass along the hosts minus few keys that are implementation detail to soxin. + (removeAttrs host [ "deploy" "mode" ]) )) darwinOnlyHosts; @@ -212,8 +212,8 @@ let ; } - # pass along the hosts minus the deploy key that's specific to soxin. - (removeAttrs host [ "deploy" ]) + # pass along the hosts minus few keys that are implementation detail to soxin. + (removeAttrs host [ "deploy" "mode" ]) )) nixosOnlyHosts; From a4633e7938dedbad2afb3be1203478c44f76d8d7 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Sun, 8 Aug 2021 21:36:29 -0700 Subject: [PATCH 04/41] send down mode as a special arg --- lib/system-flake.nix | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/system-flake.nix b/lib/system-flake.nix index 726059e..b15954b 100644 --- a/lib/system-flake.nix +++ b/lib/system-flake.nix @@ -99,7 +99,15 @@ let (hostname: host: (recursiveUpdate { specialArgs = { - inherit soxin soxincfg home-manager; + inherit + home-manager + soxin + soxincfg + ; + + inherit (host) + mode + ; } # include the global special arguments. // globalSpecialArgs @@ -162,7 +170,15 @@ let (hostname: host: (recursiveUpdate { specialArgs = { - inherit soxin soxincfg home-manager; + inherit + home-manager + soxin + soxincfg + ; + + inherit (host) + mode + ; } # include the global special arguments. // globalSpecialArgs From 2da738261e939fd212df5428710444809a988b32 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Sun, 8 Aug 2021 21:43:51 -0700 Subject: [PATCH 05/41] fix tmux inclusion --- modules/programs/tmux/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/programs/tmux/default.nix b/modules/programs/tmux/default.nix index ffdfc8b..b05b5a6 100644 --- a/modules/programs/tmux/default.nix +++ b/modules/programs/tmux/default.nix @@ -99,7 +99,9 @@ in config = mkIf cfg.enable (mkMerge [ # add all plugins installed by themes - { soxin.programs.tmux.plugins = cfg.theme.plugins; } + (optionalAttrs (mode == "NixOS" || mode == "home-manager") { + soxin.programs.tmux.plugins = cfg.theme.plugins; + }) (optionalAttrs (mode == "NixOS") (mkMerge [ { programs.tmux = { inherit (cfg) enable extraConfig secureSocket; }; } From f676629fa73f2a53349163d22bf623c8fa07be3d Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Sun, 8 Aug 2021 21:46:19 -0700 Subject: [PATCH 06/41] fix zsh inclusion --- modules/programs/zsh/default.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index abbafae..8ad989e 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -56,9 +56,13 @@ in config = mkIf cfg.enable (mkMerge [ # add all plugins installed by themes - { soxin.programs.zsh.plugins = cfg.theme.plugins; } + (optionalAttrs (mode == "NixOS" || mode == "home-manager") { + soxin.programs.zsh.plugins = cfg.theme.plugins; + }) - { programs.zsh = { inherit (cfg) enable; }; } + (optionalAttrs (mode == "NixOS" || mode == "home-manager") { + programs.zsh = { inherit (cfg) enable; }; + }) # Forward configurations to home-manager. (optionalAttrs (mode == "home-manager") { From 7a373e45ccb7116219b40b46b47c418474f680e6 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Sun, 8 Aug 2021 21:50:46 -0700 Subject: [PATCH 07/41] make sure modules are included --- lib/system-flake.nix | 82 ++++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/lib/system-flake.nix b/lib/system-flake.nix index b15954b..b9b885b 100644 --- a/lib/system-flake.nix +++ b/lib/system-flake.nix @@ -97,25 +97,32 @@ let in mapAttrs (hostname: host: (recursiveUpdate + # pass along the hosts minus few keys that are implementation detail to soxin. + (removeAttrs host [ "deploy" "mode" ]) + { - specialArgs = { - inherit - home-manager - soxin - soxincfg - ; - - inherit (host) - mode - ; - } - # include the global special arguments. - // globalSpecialArgs - # include the NixDarwin special arguments. - // nixDarwinSpecialArgs; + specialArgs = + (host.specialArgs or { }) + // + { + inherit + home-manager + soxin + soxincfg + ; + + inherit (host) + mode + ; + } + # include the global special arguments. + // globalSpecialArgs + # include the NixDarwin special arguments. + // nixDarwinSpecialArgs + ; modules = - [ ] + (host.modules or [ ]) # include sops # ++ (optionals withSops (singleton sops-nix.nixosModules.sops)) # include sane flake defaults from flake-utils-plus which sets sane `nix.*` defaults. @@ -156,9 +163,6 @@ let }) ; } - - # pass along the hosts minus few keys that are implementation detail to soxin. - (removeAttrs host [ "deploy" "mode" ]) )) darwinOnlyHosts; @@ -168,22 +172,29 @@ let in mapAttrs (hostname: host: (recursiveUpdate + # pass along the hosts minus few keys that are implementation detail to soxin. + (removeAttrs host [ "deploy" "mode" ]) + { - specialArgs = { - inherit - home-manager - soxin - soxincfg - ; - - inherit (host) - mode - ; - } - # include the global special arguments. - // globalSpecialArgs - # include the NixOS special arguments. - // nixosSpecialArgs; + specialArgs = + (host.specialArgs or { }) + // + { + inherit + home-manager + soxin + soxincfg + ; + + inherit (host) + mode + ; + } + # include the global special arguments. + // globalSpecialArgs + # include the NixOS special arguments. + // nixosSpecialArgs + ; modules = [ ] @@ -227,9 +238,6 @@ let }) ; } - - # pass along the hosts minus few keys that are implementation detail to soxin. - (removeAttrs host [ "deploy" "mode" ]) )) nixosOnlyHosts; From c6d299bf4987dcf3a0247ce0d63c2cdf4c0d0d0d Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Sun, 8 Aug 2021 21:51:50 -0700 Subject: [PATCH 08/41] fix keybase inclusion --- modules/programs/keybase/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/programs/keybase/default.nix b/modules/programs/keybase/default.nix index b50a84a..9abf0fc 100644 --- a/modules/programs/keybase/default.nix +++ b/modules/programs/keybase/default.nix @@ -16,9 +16,9 @@ in }; config = mkIf cfg.enable (mkMerge [ - { + (optionalAttrs (mode == "NixOS" || mode == "home-manager") { services.keybase.enable = true; services.kbfs.enable = cfg.enableFs; - } + }) ]); } From 7998641608e52900b4a465dad117f369bd4d68f0 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Sun, 8 Aug 2021 22:06:12 -0700 Subject: [PATCH 09/41] forgot host.modules --- lib/system-flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/system-flake.nix b/lib/system-flake.nix index b9b885b..4aee0c5 100644 --- a/lib/system-flake.nix +++ b/lib/system-flake.nix @@ -197,7 +197,7 @@ let ; modules = - [ ] + (host.modules or [ ]) # include sops ++ (optionals withSops (singleton sops-nix.nixosModules.sops)) # include sane flake defaults from flake-utils-plus which sets sane `nix.*` defaults. From ecca320a9c7bf07ac63505a9acd3ebf642574db1 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Tue, 10 Aug 2021 16:18:21 -0700 Subject: [PATCH 10/41] add default output and builder for darwin --- flake.lock | 22 +++++++ flake.nix | 3 + lib/system-flake.nix | 143 +++++++++++++++++++++++-------------------- 3 files changed, 102 insertions(+), 66 deletions(-) diff --git a/flake.lock b/flake.lock index a9fe1f9..fb8e704 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1622060422, + "narHash": "sha256-hPVlvrAyf6zL7tTx0lpK+tMxEfZeMiIZ/A2xaJ41WOY=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "007d700e644ac588ad6668e6439950a5b6e2ff64", + "type": "github" + }, + "original": { + "owner": "lnl7", + "ref": "master", + "repo": "nix-darwin", + "type": "github" + } + }, "deploy-rs": { "inputs": { "flake-compat": "flake-compat", @@ -192,6 +213,7 @@ }, "root": { "inputs": { + "darwin": "darwin", "deploy-rs": "deploy-rs", "flake-utils-plus": "flake-utils-plus", "home-manager": "home-manager", diff --git a/flake.nix b/flake.nix index f6836f0..99ffca7 100644 --- a/flake.nix +++ b/flake.nix @@ -2,6 +2,7 @@ description = "soxin: opiniated configs for everyone"; inputs = { + darwin.url = "github:lnl7/nix-darwin/master"; deploy-rs.url = "github:serokell/deploy-rs"; flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus/v1.1.0"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; @@ -9,6 +10,8 @@ nur.url = "github:nix-community/NUR"; sops-nix.url = "github:Mic92/sops-nix"; + darwin.inputs.nixpkgs.follows = "nixpkgs"; + home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/lib/system-flake.nix b/lib/system-flake.nix index 4aee0c5..f7ab68f 100644 --- a/lib/system-flake.nix +++ b/lib/system-flake.nix @@ -1,4 +1,5 @@ -{ deploy-rs +{ darwin +, deploy-rs , home-manager , flake-utils-plus , nixpkgs @@ -94,76 +95,86 @@ let darwinHosts = let darwinOnlyHosts = filterAttrs (n: host: host.mode == "nix-darwin") hosts; - in - mapAttrs - (hostname: host: (recursiveUpdate - # pass along the hosts minus few keys that are implementation detail to soxin. - (removeAttrs host [ "deploy" "mode" ]) - { - specialArgs = - (host.specialArgs or { }) - // - { - inherit - home-manager - soxin - soxincfg - ; + # Build host with darwinSystem. `removeAttrs` workaround due to https://github.com/LnL7/nix-darwin/issues/319 + builder = args: darwin.lib.darwinSystem (builtins.removeAttrs args [ "system" ]); - inherit (host) - mode - ; - } - # include the global special arguments. - // globalSpecialArgs - # include the NixDarwin special arguments. - // nixDarwinSpecialArgs - ; - - modules = - (host.modules or [ ]) - # include sops - # ++ (optionals withSops (singleton sops-nix.nixosModules.sops)) - # include sane flake defaults from flake-utils-plus which sets sane `nix.*` defaults. - # Please refer to implementation/readme in - # github:gytis-ivaskevicius/flake-utils-plus for more details. - # ++ (singleton flake-utils-plus.nixosModules.saneFlakeDefaults) - # include the nix-darwin modules - ++ extraNixDarwinModules - # include Soxin modules - ++ (singleton soxin.nixosModule) - # include home-manager modules - ++ (singleton home-manager.nixosModules.home-manager) - # configure home-manager - ++ (singleton { - # tell home-manager to use the global (as in NixOS system-level) pkgs and - # install all user packages through the users.users..packages. - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - - home-manager.extraSpecialArgs = { - inherit soxin soxincfg home-manager; - - # the mode allows us to tell at what level we are within the modules. - mode = "home-manager"; + # Setup the output + output = "darwinConfigurations"; + in + mapAttrs + (hostname: host: + # setup the default attributes, users can override it by passing them through their host definition. + { inherit builder output; } + // + (recursiveUpdate + # pass along the hosts minus few keys that are implementation detail to soxin. + (removeAttrs host [ "deploy" "mode" ]) + + { + specialArgs = + (host.specialArgs or { }) + // + { + inherit + home-manager + soxin + soxincfg + ; + + inherit (host) + mode + ; } # include the global special arguments. // globalSpecialArgs - # include the home-manager special arguments. - // hmSpecialArgs; - - home-manager.sharedModules = - # include the global modules - extraGlobalModules - # include the home-manager modules - ++ extraHomeManagerModules - # include Soxin module - ++ (singleton soxin.nixosModule); - }) - ; - } - )) + # include the NixDarwin special arguments. + // nixDarwinSpecialArgs + ; + + modules = + (host.modules or [ ]) + # include sops + # ++ (optionals withSops (singleton sops-nix.nixosModules.sops)) + # include sane flake defaults from flake-utils-plus which sets sane `nix.*` defaults. + # Please refer to implementation/readme in + # github:gytis-ivaskevicius/flake-utils-plus for more details. + # ++ (singleton flake-utils-plus.nixosModules.saneFlakeDefaults) + # include the nix-darwin modules + ++ extraNixDarwinModules + # include Soxin modules + ++ (singleton soxin.nixosModule) + # include home-manager modules + ++ (singleton home-manager.nixosModules.home-manager) + # configure home-manager + ++ (singleton { + # tell home-manager to use the global (as in NixOS system-level) pkgs and + # install all user packages through the users.users..packages. + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + + home-manager.extraSpecialArgs = { + inherit soxin soxincfg home-manager; + + # the mode allows us to tell at what level we are within the modules. + mode = "home-manager"; + } + # include the global special arguments. + // globalSpecialArgs + # include the home-manager special arguments. + // hmSpecialArgs; + + home-manager.sharedModules = + # include the global modules + extraGlobalModules + # include the home-manager modules + ++ extraHomeManagerModules + # include Soxin module + ++ (singleton soxin.nixosModule); + }) + ; + } + )) darwinOnlyHosts; nixosHosts = From b7c35d6711aa1c87587c1a05ca62d4c8c824bff1 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Tue, 10 Aug 2021 17:40:40 -0700 Subject: [PATCH 11/41] add todo --- modules/settings/keyboard.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/settings/keyboard.nix b/modules/settings/keyboard.nix index f60268c..8858900 100644 --- a/modules/settings/keyboard.nix +++ b/modules/settings/keyboard.nix @@ -76,5 +76,7 @@ in variant = concatMapStringsSep "," (l: l.x11.variant) cfg.layouts; }; }) + + # TODO: nix-darwin support ]; } From 6d74cadd63e3666afa17f063118efaff420160ad Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Tue, 10 Aug 2021 17:52:17 -0700 Subject: [PATCH 12/41] darwin hosts should include darwinModule --- lib/system-flake.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/system-flake.nix b/lib/system-flake.nix index f7ab68f..87c0443 100644 --- a/lib/system-flake.nix +++ b/lib/system-flake.nix @@ -136,16 +136,18 @@ let (host.modules or [ ]) # include sops # ++ (optionals withSops (singleton sops-nix.nixosModules.sops)) + # TODO: include sops above, or remove if unsupported. # include sane flake defaults from flake-utils-plus which sets sane `nix.*` defaults. # Please refer to implementation/readme in # github:gytis-ivaskevicius/flake-utils-plus for more details. # ++ (singleton flake-utils-plus.nixosModules.saneFlakeDefaults) + # TODO: include flake-utils-plus above, or remove if unsupported. # include the nix-darwin modules ++ extraNixDarwinModules # include Soxin modules ++ (singleton soxin.nixosModule) # include home-manager modules - ++ (singleton home-manager.nixosModules.home-manager) + ++ (singleton home-manager.darwinModules.home-manager) # configure home-manager ++ (singleton { # tell home-manager to use the global (as in NixOS system-level) pkgs and From 007ea9d9748cddd7a21a5c81659316e8c2220fb9 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Tue, 10 Aug 2021 18:04:26 -0700 Subject: [PATCH 13/41] add some R&D to the keyboard setting --- modules/settings/keyboard.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/settings/keyboard.nix b/modules/settings/keyboard.nix index 8858900..614805c 100644 --- a/modules/settings/keyboard.nix +++ b/modules/settings/keyboard.nix @@ -77,6 +77,10 @@ in }; }) - # TODO: nix-darwin support + (optionalAttrs (mode == "nix-darwin") { + # TODO: Write this up. + # Some resources: + # - https://github.com/kalbasit/shabka/blob/b6161e62e08eb323eb59fd94d4e12335507a6238/modules/darwin/general/keyboard.nix#L29-L38 + }) ]; } From 9bcb0dbd502975ca2c78b57bb9e187da9387c8f0 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Tue, 10 Aug 2021 18:24:40 -0700 Subject: [PATCH 14/41] import saneFlakeDefaults from flake-utils-plus --- lib/system-flake.nix | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/system-flake.nix b/lib/system-flake.nix index 87c0443..1191790 100644 --- a/lib/system-flake.nix +++ b/lib/system-flake.nix @@ -66,8 +66,18 @@ let soxincfg = inputs.self; inherit (nixpkgs) lib; - inherit (lib) asserts filterAttrs mapAttrs optionalAttrs optionals recursiveUpdate singleton; inherit (builtins) removeAttrs; + inherit (lib) + asserts + filterAttrs + mapAttrs + mkOption + optionalAttrs + optionals + recursiveUpdate + singleton + types + ; otherArguments = removeAttrs args [ "self" @@ -140,8 +150,15 @@ let # include sane flake defaults from flake-utils-plus which sets sane `nix.*` defaults. # Please refer to implementation/readme in # github:gytis-ivaskevicius/flake-utils-plus for more details. - # ++ (singleton flake-utils-plus.nixosModules.saneFlakeDefaults) - # TODO: include flake-utils-plus above, or remove if unsupported. + # + # First allow us to import by defining a dummy option + ++ (singleton { options.nix.registry = mkOption { + type = types.attrs; + default = { }; + description = "Unused - Makes saneFlakeDefaults from flake-utils-plus works for Mac"; + internal = true; + }; }) + ++ (singleton flake-utils-plus.nixosModules.saneFlakeDefaults) # include the nix-darwin modules ++ extraNixDarwinModules # include Soxin modules From c03aead07dd776c0e40fc16e74e4abb103d5166d Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Tue, 10 Aug 2021 18:40:53 -0700 Subject: [PATCH 15/41] do we really need this? --- lib/system-flake.nix | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/system-flake.nix b/lib/system-flake.nix index 1191790..11d88b3 100644 --- a/lib/system-flake.nix +++ b/lib/system-flake.nix @@ -151,13 +151,13 @@ let # Please refer to implementation/readme in # github:gytis-ivaskevicius/flake-utils-plus for more details. # - # First allow us to import by defining a dummy option - ++ (singleton { options.nix.registry = mkOption { - type = types.attrs; - default = { }; - description = "Unused - Makes saneFlakeDefaults from flake-utils-plus works for Mac"; - internal = true; - }; }) + # # First allow us to import by defining a dummy option + # ++ (singleton { options.nix.registry = mkOption { + # type = types.attrs; + # default = { }; + # description = "Unused - Makes saneFlakeDefaults from flake-utils-plus works for Mac"; + # internal = true; + # }; }) ++ (singleton flake-utils-plus.nixosModules.saneFlakeDefaults) # include the nix-darwin modules ++ extraNixDarwinModules From a5c3b6136a47cee329c242200c2486e019097104 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Sat, 14 Aug 2021 13:35:13 -0700 Subject: [PATCH 16/41] remove dead code --- lib/system-flake.nix | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/system-flake.nix b/lib/system-flake.nix index 11d88b3..031a3ba 100644 --- a/lib/system-flake.nix +++ b/lib/system-flake.nix @@ -151,13 +151,6 @@ let # Please refer to implementation/readme in # github:gytis-ivaskevicius/flake-utils-plus for more details. # - # # First allow us to import by defining a dummy option - # ++ (singleton { options.nix.registry = mkOption { - # type = types.attrs; - # default = { }; - # description = "Unused - Makes saneFlakeDefaults from flake-utils-plus works for Mac"; - # internal = true; - # }; }) ++ (singleton flake-utils-plus.nixosModules.saneFlakeDefaults) # include the nix-darwin modules ++ extraNixDarwinModules From d3b54c861e453ce80f1aa5c311250a3da3413c39 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Sat, 14 Aug 2021 13:35:44 -0700 Subject: [PATCH 17/41] tmux.secureSocket only on Linux --- modules/programs/tmux/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/tmux/default.nix b/modules/programs/tmux/default.nix index b05b5a6..2514d40 100644 --- a/modules/programs/tmux/default.nix +++ b/modules/programs/tmux/default.nix @@ -86,7 +86,7 @@ in secureSocket = mkOption { type = types.bool; - default = true; + default = pkgs.stdenv.isLinux; description = '' Store tmux socket under /run, which is more secure than /tmp, but as a downside it doesn't From bf4e0ad2a10c7a3f4b70e7f97ad2946fec7fe3a6 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Wed, 18 Aug 2021 11:20:32 -0700 Subject: [PATCH 18/41] the host specialArgs should come after the hardcoded ones --- lib/system-flake.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/system-flake.nix b/lib/system-flake.nix index 031a3ba..8025652 100644 --- a/lib/system-flake.nix +++ b/lib/system-flake.nix @@ -123,8 +123,6 @@ let { specialArgs = - (host.specialArgs or { }) - // { inherit home-manager @@ -136,6 +134,8 @@ let mode ; } + # include the specialArgs that were passed in. + // (host.specialArgs or { }) # include the global special arguments. // globalSpecialArgs # include the NixDarwin special arguments. @@ -200,8 +200,6 @@ let { specialArgs = - (host.specialArgs or { }) - // { inherit home-manager @@ -213,6 +211,8 @@ let mode ; } + # include the specialArgs that were passed in. + // (host.specialArgs or { }) # include the global special arguments. // globalSpecialArgs # include the NixOS special arguments. From 1f8b5026e9d715b8901dd7d483b2d348ea042bc4 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Wed, 18 Aug 2021 11:46:19 -0700 Subject: [PATCH 19/41] update the template --- template/flake.nix | 4 + template/hosts/darwins/default.nix | 41 +++++- .../minimal-darwin-system/configuration.nix | 17 +++ template/hosts/nixoses/default.nix | 28 ++++- .../minimal-nixos-system/configuration.nix | 3 +- .../nixoses/minimal-nixos-system/home.nix | 2 +- .../profiles/workstation/darwin/default.nix | 3 + .../workstation/darwin/local/default.nix | 10 ++ template/profiles/workstation/default.nix | 10 +- .../profiles/workstation/nixos/default.nix | 4 + .../workstation/nixos/local/default.nix | 10 ++ template/scripts/host.sh | 117 ++++++++++++++++++ 12 files changed, 234 insertions(+), 15 deletions(-) create mode 100644 template/hosts/darwins/minimal-darwin-system/configuration.nix create mode 100644 template/profiles/workstation/darwin/default.nix create mode 100644 template/profiles/workstation/darwin/local/default.nix create mode 100644 template/profiles/workstation/nixos/default.nix create mode 100644 template/profiles/workstation/nixos/local/default.nix create mode 100755 template/scripts/host.sh diff --git a/template/flake.nix b/template/flake.nix index 3ac5a0a..d64a5eb 100644 --- a/template/flake.nix +++ b/template/flake.nix @@ -2,15 +2,19 @@ description = "Soxin template flake"; inputs = { + darwin.url = "github:lnl7/nix-darwin/master"; deploy-rs.url = "github:serokell/deploy-rs"; flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus/v1.1.0"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/release-21.05"; nur.url = "github:nix-community/NUR"; + darwin.inputs.nixpkgs.follows = "nixpkgs"; + soxin = { url = "github:SoxinOS/soxin"; inputs = { + darwin.follows = "darwin"; deploy-rs.follows = "deploy-rs"; flake-utils-plus.follows = "flake-utils-plus"; nixpkgs-unstable.follows = "nixpkgs-unstable"; diff --git a/template/hosts/darwins/default.nix b/template/hosts/darwins/default.nix index 1671f4e..bc2be04 100644 --- a/template/hosts/darwins/default.nix +++ b/template/hosts/darwins/default.nix @@ -1,3 +1,40 @@ -inputs@{ self, deploy-rs, nixpkgs, ... }: +inputs@{ self, deploy-rs, lib ? nixpkgs.lib, nixpkgs, ... }: -{ } +let + inherit (lib) + mapAttrs + recursiveUpdate + ; + + # the default channel to follow. + channelName = "nixpkgs"; + + # the operating mode of Soxin + mode = "nix-darwin"; +in +mapAttrs + (n: v: recursiveUpdate + { + inherit + mode + ; + } + v) +{ + ### + # x86_64-darwin + ### + + minimal-darwin-system = + let + system = "x86_64-darwin"; + in + { + inherit + channelName + system + ; + + modules = [ ./minimal-darwin-system/configuration.nix ]; + }; +} diff --git a/template/hosts/darwins/minimal-darwin-system/configuration.nix b/template/hosts/darwins/minimal-darwin-system/configuration.nix new file mode 100644 index 0000000..2a9ab1c --- /dev/null +++ b/template/hosts/darwins/minimal-darwin-system/configuration.nix @@ -0,0 +1,17 @@ +{ config, lib, soxincfg, ... }: + +let + inherit (lib) singleton; +in +{ + imports = [ + # import the workstation profile that configures a workstation. + soxincfg.nixosModules.profiles.workstation.darwin.local + ]; + + # the user nick is created by the core profiles which is automatically added + # to the configuration of all supported systems. + home-manager.users.nick = { ... }: { + imports = singleton ./home.nix; + }; +} diff --git a/template/hosts/nixoses/default.nix b/template/hosts/nixoses/default.nix index 7c981a6..082c73e 100644 --- a/template/hosts/nixoses/default.nix +++ b/template/hosts/nixoses/default.nix @@ -1,6 +1,30 @@ -inputs@{ self, deploy-rs, ... }: +inputs@{ self, deploy-rs, lib ? nixpkgs.lib, nixpkgs, ... }: +let + inherit (lib) + mapAttrs + recursiveUpdate + ; + + # the default channel to follow. + channelName = "nixpkgs"; + + # the operating mode of Soxin + mode = "NixOS"; +in +mapAttrs + (n: v: recursiveUpdate + { + inherit + mode + ; + } + v) { + ### + # x86_64-linux + ### + minimal-nixos-system = let system = "x86_64-linux"; @@ -9,7 +33,7 @@ inputs@{ self, deploy-rs, ... }: # System architecture. inherit system; # of the channel to be used. Defaults to `nixpkgs` - channelName = "nixpkgs"; + inherit channelName; # Extra arguments to be passed to the modules. extraArgs = { }; # Host specific configuration. diff --git a/template/hosts/nixoses/minimal-nixos-system/configuration.nix b/template/hosts/nixoses/minimal-nixos-system/configuration.nix index bd77ad4..1167eba 100644 --- a/template/hosts/nixoses/minimal-nixos-system/configuration.nix +++ b/template/hosts/nixoses/minimal-nixos-system/configuration.nix @@ -9,10 +9,9 @@ in ./hardware-configuration.nix # import the workstation profile that configures a workstation. - soxincfg.nixosModules.profiles.workstation + soxincfg.nixosModules.profiles.workstation.nixos.local ]; - # the user nick is created by the core profiles which is automatically added # to the configuration of all supported systems. home-manager.users.nick = { ... }: { diff --git a/template/hosts/nixoses/minimal-nixos-system/home.nix b/template/hosts/nixoses/minimal-nixos-system/home.nix index 3cfd501..802cc04 100644 --- a/template/hosts/nixoses/minimal-nixos-system/home.nix +++ b/template/hosts/nixoses/minimal-nixos-system/home.nix @@ -4,7 +4,7 @@ let inherit (lib) singleton; in { - imports = [ soxincfg.nixosModules.profiles.workstation ]; + imports = [ soxincfg.nixosModules.profiles.workstation.nixos.local ]; home.packages = with soxincfg.packages."${pkgs.system}"; singleton helloSh; diff --git a/template/profiles/workstation/darwin/default.nix b/template/profiles/workstation/darwin/default.nix new file mode 100644 index 0000000..099964e --- /dev/null +++ b/template/profiles/workstation/darwin/default.nix @@ -0,0 +1,3 @@ +{ + local = import ./local; +} diff --git a/template/profiles/workstation/darwin/local/default.nix b/template/profiles/workstation/darwin/local/default.nix new file mode 100644 index 0000000..7108179 --- /dev/null +++ b/template/profiles/workstation/darwin/local/default.nix @@ -0,0 +1,10 @@ +{ lib, ... }: + +let + inherit (lib) mkMerge; +in +{ + config = mkMerge [ + { soxin.programs.zsh.enable = true; } + ]; +} diff --git a/template/profiles/workstation/default.nix b/template/profiles/workstation/default.nix index 765c9f7..a91d764 100644 --- a/template/profiles/workstation/default.nix +++ b/template/profiles/workstation/default.nix @@ -1,10 +1,4 @@ -{ lib, ... }: - -let - inherit (lib) mkMerge; -in { - config = mkMerge [ - { soxin.hardware.bluetooth.enable = true; } - ]; + darwin = import ./darwin; + nixos = import ./nixos; } diff --git a/template/profiles/workstation/nixos/default.nix b/template/profiles/workstation/nixos/default.nix new file mode 100644 index 0000000..b82905b --- /dev/null +++ b/template/profiles/workstation/nixos/default.nix @@ -0,0 +1,4 @@ +{ + local = import ./local; + # remote = import ./remote; +} diff --git a/template/profiles/workstation/nixos/local/default.nix b/template/profiles/workstation/nixos/local/default.nix new file mode 100644 index 0000000..7108179 --- /dev/null +++ b/template/profiles/workstation/nixos/local/default.nix @@ -0,0 +1,10 @@ +{ lib, ... }: + +let + inherit (lib) mkMerge; +in +{ + config = mkMerge [ + { soxin.programs.zsh.enable = true; } + ]; +} diff --git a/template/scripts/host.sh b/template/scripts/host.sh new file mode 100755 index 0000000..76de8f7 --- /dev/null +++ b/template/scripts/host.sh @@ -0,0 +1,117 @@ +#!/usr/bin/env bash + +set -euo pipefail + +readonly action="${1:-}" +readonly host="${2:-$(hostname)}" + +isDarwin() { + local os="$(uname -s)" + [[ "${os}" == "Darwin" ]] +} + +isLinux() { + local os="$(uname -s)" + [[ "${os}" == "Linux" ]] +} + +isNixOS() { + has nixos-version +} + +# Usage: has +# +# Returns 0 if the is available. Returns 1 otherwise. It can be a +# binary in the PATH or a shell function. +# +# Example: +# +# if has curl; then +# echo "Yes we do" +# fi +# +has() { + type "$1" &>/dev/null +} + +isSupported() { + isNixOS && return 0 + isDarwin && return 0 + + if [[ -f /etc/os-release ]]; then + local os="$(awk -F= '/^ID=/ {print $2}' /etc/os-release | tr -d '\n')" + case "$os" in + nixos|debian) + return 0 + ;; + *) + return 1 + ;; + esac + fi + + return 1 +} + +if ! isSupported; then + echo "Sorry, your operating system is not supported" + exit 1 +fi + +function usage() { + >&2 echo "USAGE: $0 [hostname]" +} + +if [[ -z "${action:-}" ]]; then + usage + exit 1 +fi + +case "${action}" in + build) + if isNixOS; then + nix build ".#nixosConfigurations.${host}.config.system.build.toplevel" --show-trace + elif isDarwin; then + nix build ".#darwinConfigurations.${host}.system" --show-trace + else + home-manager build --flake ".#${host}" --show-trace + fi + ;; + test) + if isNixOS; then + sudo nixos-rebuild --flake ".#${host}" test --show-trace + elif isDarwin; then + >&2 echo test is not support on nix-darwin + exit 1 + else + >&2 echo test is not support on home-manager + exit 1 + fi + ;; + switch) + if isNixOS; then + sudo nixos-rebuild --flake ".#${host}" test --show-trace + elif isDarwin; then + "$0" build "$host" + sudo ./result/activate + ./result/activate-user + else + home-manager switch --flake ".#${host}" + fi + ;; + boot) + if isNixOS; then + sudo nixos-rebuild --flake ".#${host}" boot --show-trace + elif isDarwin; then + >&2 echo boot is not support on nix-darwin + exit 1 + else + >&2 echo boot is not support on home-manager + exit 1 + fi + ;; + *) + usage + exit 1 + ;; +esac From d2d3809cb739f791c42a2c6b5840b163de548b31 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Wed, 18 Aug 2021 11:46:55 -0700 Subject: [PATCH 20/41] remove the host script I will incude it later in a documentation pull request --- template/scripts/host.sh | 117 --------------------------------------- 1 file changed, 117 deletions(-) delete mode 100755 template/scripts/host.sh diff --git a/template/scripts/host.sh b/template/scripts/host.sh deleted file mode 100755 index 76de8f7..0000000 --- a/template/scripts/host.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -readonly action="${1:-}" -readonly host="${2:-$(hostname)}" - -isDarwin() { - local os="$(uname -s)" - [[ "${os}" == "Darwin" ]] -} - -isLinux() { - local os="$(uname -s)" - [[ "${os}" == "Linux" ]] -} - -isNixOS() { - has nixos-version -} - -# Usage: has -# -# Returns 0 if the is available. Returns 1 otherwise. It can be a -# binary in the PATH or a shell function. -# -# Example: -# -# if has curl; then -# echo "Yes we do" -# fi -# -has() { - type "$1" &>/dev/null -} - -isSupported() { - isNixOS && return 0 - isDarwin && return 0 - - if [[ -f /etc/os-release ]]; then - local os="$(awk -F= '/^ID=/ {print $2}' /etc/os-release | tr -d '\n')" - case "$os" in - nixos|debian) - return 0 - ;; - *) - return 1 - ;; - esac - fi - - return 1 -} - -if ! isSupported; then - echo "Sorry, your operating system is not supported" - exit 1 -fi - -function usage() { - >&2 echo "USAGE: $0 [hostname]" -} - -if [[ -z "${action:-}" ]]; then - usage - exit 1 -fi - -case "${action}" in - build) - if isNixOS; then - nix build ".#nixosConfigurations.${host}.config.system.build.toplevel" --show-trace - elif isDarwin; then - nix build ".#darwinConfigurations.${host}.system" --show-trace - else - home-manager build --flake ".#${host}" --show-trace - fi - ;; - test) - if isNixOS; then - sudo nixos-rebuild --flake ".#${host}" test --show-trace - elif isDarwin; then - >&2 echo test is not support on nix-darwin - exit 1 - else - >&2 echo test is not support on home-manager - exit 1 - fi - ;; - switch) - if isNixOS; then - sudo nixos-rebuild --flake ".#${host}" test --show-trace - elif isDarwin; then - "$0" build "$host" - sudo ./result/activate - ./result/activate-user - else - home-manager switch --flake ".#${host}" - fi - ;; - boot) - if isNixOS; then - sudo nixos-rebuild --flake ".#${host}" boot --show-trace - elif isDarwin; then - >&2 echo boot is not support on nix-darwin - exit 1 - else - >&2 echo boot is not support on home-manager - exit 1 - fi - ;; - *) - usage - exit 1 - ;; -esac From 733505d96eca7c64275bb63e7625750e17850b40 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Wed, 18 Aug 2021 11:56:25 -0700 Subject: [PATCH 21/41] add darwin home --- .../hosts/darwins/minimal-darwin-system/home.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 template/hosts/darwins/minimal-darwin-system/home.nix diff --git a/template/hosts/darwins/minimal-darwin-system/home.nix b/template/hosts/darwins/minimal-darwin-system/home.nix new file mode 100644 index 0000000..9caca06 --- /dev/null +++ b/template/hosts/darwins/minimal-darwin-system/home.nix @@ -0,0 +1,12 @@ +{ lib, soxincfg, pkgs, ... }: + +let + inherit (lib) singleton; +in +{ + imports = [ soxincfg.nixosModules.profiles.workstation.darwin.local ]; + + home.packages = with soxincfg.packages."${pkgs.system}"; singleton helloSh; + + programs.zsh.enable = true; +} From 0642cfe7cc81ff3082fe65af34ac91292da8a2cd Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Wed, 18 Aug 2021 12:04:35 -0700 Subject: [PATCH 22/41] remove unused hostname variable --- lib/system-flake.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/system-flake.nix b/lib/system-flake.nix index 8025652..bbbb56e 100644 --- a/lib/system-flake.nix +++ b/lib/system-flake.nix @@ -113,7 +113,7 @@ let output = "darwinConfigurations"; in mapAttrs - (hostname: host: + (_: host: # setup the default attributes, users can override it by passing them through their host definition. { inherit builder output; } // @@ -194,7 +194,7 @@ let nixosOnlyHosts = filterAttrs (n: host: host.mode == "NixOS") hosts; in mapAttrs - (hostname: host: (recursiveUpdate + (_: host: (recursiveUpdate # pass along the hosts minus few keys that are implementation detail to soxin. (removeAttrs host [ "deploy" "mode" ]) @@ -274,7 +274,7 @@ let # filter out hosts without a deploy attribute. deploy-hosts = filterAttrs (n: v: (v.deploy or { }) != { }) hosts; in - mapAttrs (hostname: host: host.deploy) deploy-hosts; + mapAttrs (_: host: host.deploy) deploy-hosts; soxinSystemFlake = { # inherit the required fields as-is @@ -385,7 +385,7 @@ flake-utils-plus.lib.systemFlake (recursiveUpdate soxinSystemFlake otherArgument # TODO: Let flake-utils-plus.lib.systemFlake handle the home-managers by using the host's builder function // { homeConfigurations = (mapAttrs - (hostname: host: soxin.lib.homeManagerConfiguration (host // { + (_: host: soxin.lib.homeManagerConfiguration (host // { inherit inputs; hmModules = # include the global modules From 725e7ec5e37cd2ae83720b00d198c3feed334ab7 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Wed, 18 Aug 2021 13:05:17 -0700 Subject: [PATCH 23/41] add more stuff --- template/flake.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/template/flake.nix b/template/flake.nix index d64a5eb..1f8e58b 100644 --- a/template/flake.nix +++ b/template/flake.nix @@ -5,6 +5,7 @@ darwin.url = "github:lnl7/nix-darwin/master"; deploy-rs.url = "github:serokell/deploy-rs"; flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus/v1.1.0"; + nixos-hardware.url = "github:NixOS/nixos-hardware"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/release-21.05"; nur.url = "github:nix-community/NUR"; @@ -24,7 +25,7 @@ }; }; - outputs = inputs@{ flake-utils-plus, nixpkgs, self, soxin, ... }: + outputs = inputs@{ flake-utils-plus, nixos-hardware, nixpkgs, self, soxin, ... }: let # Enable deploy-rs support withDeploy = true; @@ -56,6 +57,7 @@ channelsConfig = { # allowBroken = true; allowUnfree = true; + # allowUnsupportedSystem = true; }; nixosModules = (import ./modules) // { @@ -89,5 +91,8 @@ # include all overlays overlay = import ./overlays; + + # set the nixos specialArgs + nixosSpecialArgs = { inherit nixos-hardware; }; }; } From 1b11e63fcbda5156d802ce0b4098fa50b186ca5e Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Wed, 18 Aug 2021 13:09:42 -0700 Subject: [PATCH 24/41] put the merge on the next line --- template/hosts/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/hosts/default.nix b/template/hosts/default.nix index b6d0144..040f7cd 100644 --- a/template/hosts/default.nix +++ b/template/hosts/default.nix @@ -1,4 +1,4 @@ inputs@{ ... }: -(import ./nixoses inputs) // -(import ./darwins inputs) +(import ./nixoses inputs) + // (import ./darwins inputs) From 21897e8b59c618a1f3cf3d4954e87fd6329f5b3d Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Wed, 18 Aug 2021 14:09:14 -0700 Subject: [PATCH 25/41] enable verbose mode --- lib/system-flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/system-flake.nix b/lib/system-flake.nix index bbbb56e..51f881f 100644 --- a/lib/system-flake.nix +++ b/lib/system-flake.nix @@ -164,6 +164,7 @@ let # install all user packages through the users.users..packages. home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; + home-manager.verbose = true; home-manager.extraSpecialArgs = { inherit soxin soxincfg home-manager; From 6758b1e17f9ef635f6c43876a76444dc9fc5615e Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Wed, 18 Aug 2021 14:25:14 -0700 Subject: [PATCH 26/41] Revert "enable verbose mode" This reverts commit 21897e8b59c618a1f3cf3d4954e87fd6329f5b3d. --- lib/system-flake.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/system-flake.nix b/lib/system-flake.nix index 51f881f..bbbb56e 100644 --- a/lib/system-flake.nix +++ b/lib/system-flake.nix @@ -164,7 +164,6 @@ let # install all user packages through the users.users..packages. home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; - home-manager.verbose = true; home-manager.extraSpecialArgs = { inherit soxin soxincfg home-manager; From ca3f7a9a1a7cffc3d019fe52709982e58a1deb90 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Wed, 18 Aug 2021 14:27:30 -0700 Subject: [PATCH 27/41] enable zsh on nix-darwin --- modules/programs/zsh/default.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index 8ad989e..b86188f 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -55,12 +55,15 @@ in }; config = mkIf cfg.enable (mkMerge [ - # add all plugins installed by themes (optionalAttrs (mode == "NixOS" || mode == "home-manager") { + programs.zsh = { inherit (cfg) enable; }; + + # add all plugins installed by themes soxin.programs.zsh.plugins = cfg.theme.plugins; }) - (optionalAttrs (mode == "NixOS" || mode == "home-manager") { + # Forward configurations to nix-darwin. + (optionalAttrs (mode == "nix-darwin") { programs.zsh = { inherit (cfg) enable; }; }) From 63c8815c2aab5baf357423173f0a382cac32a79c Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Wed, 18 Aug 2021 15:37:29 -0700 Subject: [PATCH 28/41] forward plugins to nix-darwin --- modules/programs/zsh/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index b86188f..7402170 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -77,10 +77,10 @@ in programs.zsh.autosuggestions.enable = cfg.enableAutosuggestions; }) - # Forward plugins to NixOS. + # Forward plugins to NixOS and home-manager. # Copy the plugin management from home-manager - # TODO: Send it upstream to NixOS. - (optionalAttrs (mode == "NixOS") (mkIf (cfg.plugins != [ ]) { + # TODO: Send it upstream to NixOS and nix-darwin. + (optionalAttrs (mode == "NixOS" || mode == "nix-darwin") (mkIf (cfg.plugins != [ ]) { # Many plugins require compinit to be called # but allow the user to opt out. programs.zsh.enableCompletion = mkDefault true; From ed2b9ec35d342f2aa7262aed766f36ea049e21dd Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Wed, 18 Aug 2021 15:44:06 -0700 Subject: [PATCH 29/41] organise them for easier reading --- modules/programs/zsh/default.nix | 42 +++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index 7402170..e02265f 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -14,12 +14,19 @@ in includeTheme = true; # TODO: copied from home-manager, fix this! extraOptions = { - # TODO: Consider taking one from NixOS because of the strategy feature! + # TODO: Consider taking this one from NixOS because of the strategy feature! enableAutosuggestions = mkOption { default = true; type = types.bool; description = "Enable zsh autosuggestions"; }; + + enableCompletion = mkOption { + default = true; + type = types.bool; + description = "Enable zsh auto-completion"; + }; + plugins = mkOption { # type = types.listOf soxin.lib.modules.zsh.pluginModule; @@ -62,28 +69,12 @@ in soxin.programs.zsh.plugins = cfg.theme.plugins; }) - # Forward configurations to nix-darwin. - (optionalAttrs (mode == "nix-darwin") { - programs.zsh = { inherit (cfg) enable; }; - }) - - # Forward configurations to home-manager. - (optionalAttrs (mode == "home-manager") { - programs.zsh = { inherit (cfg) enableAutosuggestions plugins; }; - }) - - # Forward configurations to NixOS. - (optionalAttrs (mode == "NixOS") { - programs.zsh.autosuggestions.enable = cfg.enableAutosuggestions; - }) - - # Forward plugins to NixOS and home-manager. - # Copy the plugin management from home-manager + # Copy the plugin management from home-manager to send plugins to NixOS and nix-darwin # TODO: Send it upstream to NixOS and nix-darwin. (optionalAttrs (mode == "NixOS" || mode == "nix-darwin") (mkIf (cfg.plugins != [ ]) { # Many plugins require compinit to be called # but allow the user to opt out. - programs.zsh.enableCompletion = mkDefault true; + soxin.programs.zsh.enableCompletion = mkDefault true; environment.etc = foldl' (a: b: a // b) { } @@ -98,6 +89,19 @@ in cfg.plugins); })) + (optionalAttrs (mode == "NixOS") { + programs.zsh = { inherit (cfg) enableCompletion; }; + programs.zsh.autosuggestions.enable = cfg.enableAutosuggestions; + }) + + (optionalAttrs (mode == "nix-darwin") { + programs.zsh = { inherit (cfg) enable enableCompletion; }; + }) + + (optionalAttrs (mode == "home-manager") { + programs.zsh = { inherit (cfg) enableAutosuggestions plugins; }; + }) + # install all completions libraries for system packages (optionalAttrs (mode == "NixOS") (mkIf config.programs.zsh.enableCompletion { environment.pathsToLink = [ "/share/zsh" ]; From 5926932f0aa97cb55878375b2dcc7962640b8cf3 Mon Sep 17 00:00:00 2001 From: Wael Nasreddine Date: Mon, 28 Mar 2022 22:25:01 -0700 Subject: [PATCH 30/41] wip --- lib/mk-flake.nix | 90 ++---------------------------------------------- 1 file changed, 2 insertions(+), 88 deletions(-) diff --git a/lib/mk-flake.nix b/lib/mk-flake.nix index 1a525d0..ec49eb8 100644 --- a/lib/mk-flake.nix +++ b/lib/mk-flake.nix @@ -123,8 +123,8 @@ let let darwinOnlyHosts = filterAttrs (n: host: host.mode == "nix-darwin") hosts; - # Build host with darwinSystem. `removeAttrs` workaround due to https://github.com/LnL7/nix-darwin/issues/319 - builder = args: darwin.lib.darwinSystem (builtins.removeAttrs args [ "system" ]); + # Build host with darwinSystem. + builder = args: darwin.lib.darwinSystem args; # Setup the output output = "darwinConfigurations"; @@ -158,50 +158,6 @@ let # include the NixDarwin special arguments. // nixDarwinSpecialArgs ; - - modules = - (host.modules or [ ]) - # include sops - # ++ (optionals withSops (singleton sops-nix.nixosModules.sops)) - # TODO: include sops above, or remove if unsupported. - # include sane flake defaults from flake-utils-plus which sets sane `nix.*` defaults. - # Please refer to implementation/readme in - # github:gytis-ivaskevicius/flake-utils-plus for more details. - # - ++ (singleton flake-utils-plus.nixosModules.saneFlakeDefaults) - # include the nix-darwin modules - ++ extraNixDarwinModules - # include Soxin modules - ++ (singleton soxin.nixosModule) - # include home-manager modules - ++ (singleton home-manager.darwinModules.home-manager) - # configure home-manager - ++ (singleton { - # tell home-manager to use the global (as in NixOS system-level) pkgs and - # install all user packages through the users.users..packages. - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - - home-manager.extraSpecialArgs = { - inherit soxin soxincfg home-manager; - - # the mode allows us to tell at what level we are within the modules. - mode = "home-manager"; - } - # include the global special arguments. - // globalSpecialArgs - # include the home-manager special arguments. - // hmSpecialArgs; - - home-manager.sharedModules = - # include the global modules - extraGlobalModules - # include the home-manager modules - ++ extraHomeManagerModules - # include Soxin module - ++ (singleton soxin.nixosModule); - }) - ; } )) darwinOnlyHosts; @@ -235,48 +191,6 @@ let # include the NixOS special arguments. // nixosSpecialArgs ; - - modules = - (host.modules or [ ]) - # include sops - ++ (optionals withSops (singleton sops-nix.nixosModules.sops)) - # include sane flake defaults from flake-utils-plus which sets sane `nix.*` defaults. - # Please refer to implementation/readme in - # github:gytis-ivaskevicius/flake-utils-plus for more details. - ++ (singleton flake-utils-plus.nixosModules.saneFlakeDefaults) - # include the NixOS modules - ++ extraNixosModules - # include Soxin modules - ++ (singleton soxin.nixosModule) - # include home-manager modules - ++ (singleton home-manager.nixosModules.home-manager) - # configure home-manager - ++ (singleton { - # tell home-manager to use the global (as in NixOS system-level) pkgs and - # install all user packages through the users.users..packages. - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - - home-manager.extraSpecialArgs = { - inherit soxin soxincfg home-manager; - - # the mode allows us to tell at what level we are within the modules. - mode = "home-manager"; - } - # include the global special arguments. - // globalSpecialArgs - # include the home-manager special arguments. - // hmSpecialArgs; - - home-manager.sharedModules = - # include the global modules - extraGlobalModules - # include the home-manager modules - ++ extraHomeManagerModules - # include Soxin module - ++ (singleton soxin.nixosModule); - }) - ; } )) nixosOnlyHosts; From f97a53d5ff741c18adefb5b284b796070f6ac7f9 Mon Sep 17 00:00:00 2001 From: Wael Nasreddine Date: Mon, 28 Mar 2022 23:09:21 -0700 Subject: [PATCH 31/41] fix the location of modules --- lib/mk-flake.nix | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/mk-flake.nix b/lib/mk-flake.nix index ec49eb8..aa5a6af 100644 --- a/lib/mk-flake.nix +++ b/lib/mk-flake.nix @@ -139,6 +139,12 @@ let (removeAttrs host [ "deploy" "mode" ]) { + modules = [ ] + # include the NixOS modules + ++ extraNixDarwinModules + # include home-manager modules + ++ (singleton home-manager.darwinModules.home-manager) + ; specialArgs = { inherit @@ -172,6 +178,13 @@ let (removeAttrs host [ "deploy" "mode" ]) { + modules = [ ] + # include the NixOS modules + ++ extraNixosModules + # include home-manager modules + ++ (singleton home-manager.nixosModules.home-manager) + ; + specialArgs = { inherit @@ -307,12 +320,8 @@ let (hostDefaults.modules or [ ]) # include the global modules ++ extraGlobalModules - # include the NixOS modules - ++ extraNixosModules # include Soxin modules ++ (singleton soxin.nixosModule) - # include home-manager modules - ++ (singleton home-manager.nixosModules.home-manager) # configure fup to expose NIX_PATH and Nix registry from inputs. ++ (singleton { nix = { inherit generateNixPathFromInputs generateRegistryFromInputs linkInputs; }; }) # configure home-manager @@ -331,7 +340,8 @@ let # include the global special arguments. // globalSpecialArgs # include the home-manager special arguments. - // hmSpecialArgs; + // hmSpecialArgs + ; home-manager.sharedModules = # include the global modules @@ -339,7 +349,8 @@ let # include the home-manager modules ++ extraHomeManagerModules # include Soxin module - ++ (singleton soxin.nixosModule); + ++ (singleton soxin.nixosModule) + ; }); }; } From bfbcd86a259811e29c306094e882440331dab99c Mon Sep 17 00:00:00 2001 From: Wael Nasreddine Date: Thu, 31 Mar 2022 13:08:25 -0700 Subject: [PATCH 32/41] fix --- lib/mk-flake.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/mk-flake.nix b/lib/mk-flake.nix index aa5a6af..4ab18be 100644 --- a/lib/mk-flake.nix +++ b/lib/mk-flake.nix @@ -136,10 +136,12 @@ let // (recursiveUpdate # pass along the hosts minus few keys that are implementation detail to soxin. - (removeAttrs host [ "deploy" "mode" ]) + (removeAttrs host [ "deploy" "mode" "modules" ]) { modules = [ ] + # include modules for the host + ++ (host.modules or [ ]) # include the NixOS modules ++ extraNixDarwinModules # include home-manager modules @@ -179,6 +181,8 @@ let { modules = [ ] + # include modules for the host + ++ (host.modules or [ ]) # include the NixOS modules ++ extraNixosModules # include home-manager modules @@ -326,8 +330,9 @@ let ++ (singleton { nix = { inherit generateNixPathFromInputs generateRegistryFromInputs linkInputs; }; }) # configure home-manager ++ (singleton { - # tell home-manager to use the global (as in NixOS system-level) pkgs and - # install all user packages through the users.users..packages. + # tell home-manager to use the global (as in NixOS/Nix-Darwin + # system-level) pkgs and install all user packages through the + # users.users..packages. home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; From 3c4db9bcd32bf142415fda8f7f9f20479f047b4c Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Thu, 31 Mar 2022 13:21:26 -0700 Subject: [PATCH 33/41] add missing sops module --- lib/mk-flake.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/mk-flake.nix b/lib/mk-flake.nix index 4ab18be..ebf2c8f 100644 --- a/lib/mk-flake.nix +++ b/lib/mk-flake.nix @@ -185,6 +185,8 @@ let ++ (host.modules or [ ]) # include the NixOS modules ++ extraNixosModules + # include sops + ++ (optionals withSops (singleton sops-nix.nixosModules.sops)) # include home-manager modules ++ (singleton home-manager.nixosModules.home-manager) ; From 29da32fa71841beb4d6861af40b8e19cf3acf5d6 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Tue, 5 Apr 2022 07:09:18 -0700 Subject: [PATCH 34/41] wip --- modules/programs/keybase/default.nix | 15 +++++++++-- modules/programs/starship/default.nix | 38 +++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/modules/programs/keybase/default.nix b/modules/programs/keybase/default.nix index 9abf0fc..5c5bd65 100644 --- a/modules/programs/keybase/default.nix +++ b/modules/programs/keybase/default.nix @@ -1,8 +1,19 @@ { mode, config, pkgs, lib, ... }: -with lib; let cfg = config.soxin.programs.keybase; + + inherit (lib) + mkEnableOption + mkIf + mkMerge + optionalAttrs + recursiveUpdate + ; + + inherit (pkgs.hostPlatform) + isLinux + ; in { options = { @@ -11,7 +22,7 @@ in enableFs = recursiveUpdate (mkEnableOption "Keybase filesystem") - { default = true; }; + { default = isLinux; }; }; }; diff --git a/modules/programs/starship/default.nix b/modules/programs/starship/default.nix index 2b08155..7a050f8 100644 --- a/modules/programs/starship/default.nix +++ b/modules/programs/starship/default.nix @@ -1,8 +1,19 @@ { mode, config, pkgs, lib, ... }: -with lib; let cfg = config.soxin.programs.starship; + + inherit (lib) + mkEnableOption + mkAfter + mkIf + mkMerge + optionalAttrs + ; + + inherit (pkgs.hostPlatform) + isDarwin + ; in { options = { @@ -21,10 +32,27 @@ in }) (optionalAttrs (mode == "home-manager") { - programs.starship = { - enable = true; - enableZshIntegration = config.soxin.programs.zsh.enable; - }; + programs.starship = mkMerge [ + { + enable = true; + enableZshIntegration = config.soxin.programs.zsh.enable; + } + + (mkIf (isDarwin /* TODO: && M1 only */) { + package = pkgs.writeShellScriptBin "starship" '' + set -euo pipefail + + readonly real_path=/opt/homebrew/bin/starship + + if [[ ! -x $real_path ]]; then + >&2 echo "Installing starship, please wait." + brew install starship + fi + + exec $real_path "$@" + ''; + }) + ]; }) ]); } From 14c744dd613097be0accb7ea7e0cbbce34263b21 Mon Sep 17 00:00:00 2001 From: Wael Nasreddine Date: Mon, 30 May 2022 12:01:30 -0700 Subject: [PATCH 35/41] Update flake.nix Co-authored-by: risson <18313093+rissson@users.noreply.github.com> --- flake.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index f449f31..2548d18 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,10 @@ description = "soxin: opiniated configs for everyone"; inputs = { - darwin.url = "github:lnl7/nix-darwin/master"; + darwin = { + url = "github:lnl7/nix-darwin/master"; + inputs.nixpkgs.follows = "nixpkgs"; + }; deploy-rs.url = "github:serokell/deploy-rs"; flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus/v1.3.1"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; @@ -10,8 +13,6 @@ nur.url = "github:nix-community/NUR"; sops-nix.url = "github:Mic92/sops-nix"; - darwin.inputs.nixpkgs.follows = "nixpkgs"; - home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; From 49c37c3d508acf1061e6367b1f08f0f36ba94ffb Mon Sep 17 00:00:00 2001 From: Wael Nasreddine Date: Mon, 30 May 2022 23:34:25 -0700 Subject: [PATCH 36/41] fix the M1 only issue --- modules/programs/starship/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/starship/default.nix b/modules/programs/starship/default.nix index 7a050f8..d729348 100644 --- a/modules/programs/starship/default.nix +++ b/modules/programs/starship/default.nix @@ -38,7 +38,7 @@ in enableZshIntegration = config.soxin.programs.zsh.enable; } - (mkIf (isDarwin /* TODO: && M1 only */) { + (mkIf (isDarwin && pkgs.system == "aarch64-darwin") { package = pkgs.writeShellScriptBin "starship" '' set -euo pipefail From ad882ec31f8ce6b83650dbfbdda5a33a8c6b1960 Mon Sep 17 00:00:00 2001 From: Wael Nasreddine Date: Tue, 29 Aug 2023 23:00:35 -0700 Subject: [PATCH 37/41] remove stuff coming from git conflict resolve --- lib/mk-flake.nix | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/mk-flake.nix b/lib/mk-flake.nix index c4589ea..ecc7e94 100644 --- a/lib/mk-flake.nix +++ b/lib/mk-flake.nix @@ -50,9 +50,6 @@ # nix-darwin specific extra arguments. , nixDarwinSpecialArgs ? { } - # Evaluates to `packages.. = .`. -, packagesBuilder ? (_: { }) - # Shared overlays between channels, gets applied to all `channels..input` , sharedOverlays ? [ ] @@ -110,8 +107,6 @@ let "hmSpecialArgs" "nixosSpecialArgs" "nixDarwinSpecialArgs" - "packagesBuilder" - "devShellBuilder" "outputsBuilder" "sharedOverlays" ]; From 74354cf6cd429ce41a58a1e99e6f0f403ca987c0 Mon Sep 17 00:00:00 2001 From: Wael Nasreddine Date: Tue, 29 Aug 2023 23:10:03 -0700 Subject: [PATCH 38/41] revert starship changes, not needed anymore --- modules/programs/starship/default.nix | 38 ++++----------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/modules/programs/starship/default.nix b/modules/programs/starship/default.nix index d729348..2b08155 100644 --- a/modules/programs/starship/default.nix +++ b/modules/programs/starship/default.nix @@ -1,19 +1,8 @@ { mode, config, pkgs, lib, ... }: +with lib; let cfg = config.soxin.programs.starship; - - inherit (lib) - mkEnableOption - mkAfter - mkIf - mkMerge - optionalAttrs - ; - - inherit (pkgs.hostPlatform) - isDarwin - ; in { options = { @@ -32,27 +21,10 @@ in }) (optionalAttrs (mode == "home-manager") { - programs.starship = mkMerge [ - { - enable = true; - enableZshIntegration = config.soxin.programs.zsh.enable; - } - - (mkIf (isDarwin && pkgs.system == "aarch64-darwin") { - package = pkgs.writeShellScriptBin "starship" '' - set -euo pipefail - - readonly real_path=/opt/homebrew/bin/starship - - if [[ ! -x $real_path ]]; then - >&2 echo "Installing starship, please wait." - brew install starship - fi - - exec $real_path "$@" - ''; - }) - ]; + programs.starship = { + enable = true; + enableZshIntegration = config.soxin.programs.zsh.enable; + }; }) ]); } From 430c51724debc6dd94b20f06e7603ec128d3e44d Mon Sep 17 00:00:00 2001 From: Wael Nasreddine Date: Tue, 29 Aug 2023 23:21:55 -0700 Subject: [PATCH 39/41] fix the template build --- template/flake.nix | 22 ++++++++++++++----- .../darwins/minimal-darwin-system/home.nix | 2 ++ .../nixoses/minimal-nixos-system/home.nix | 2 ++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/template/flake.nix b/template/flake.nix index 4b3607c..9f51c6a 100644 --- a/template/flake.nix +++ b/template/flake.nix @@ -2,19 +2,29 @@ description = "Soxin template flake"; inputs = { - darwin.url = "github:lnl7/nix-darwin/master"; deploy-rs.url = "github:serokell/deploy-rs"; - flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus/v1.3.1"; - home-manager.url = "github:nix-community/home-manager/release-21.11"; + flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus"; nixos-hardware.url = "github:NixOS/nixos-hardware"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; - nixpkgs.url = "github:NixOS/nixpkgs/release-21.11"; + nixpkgs.url = "github:NixOS/nixpkgs/release-23.05"; nur.url = "github:nix-community/NUR"; - darwin.inputs.nixpkgs.follows = "nixpkgs"; + home-manager = { + url = "github:nix-community/home-manager/release-23.05"; + inputs = { + nixpkgs.follows = "nixpkgs"; + }; + }; + + darwin = { + url = "github:LnL7/nix-darwin"; + inputs = { + nixpkgs.follows = "nixpkgs"; + }; + }; soxin = { - url = "github:SoxinOS/soxin"; + url = "path:../"; inputs = { darwin.follows = "darwin"; deploy-rs.follows = "deploy-rs"; diff --git a/template/hosts/darwins/minimal-darwin-system/home.nix b/template/hosts/darwins/minimal-darwin-system/home.nix index 9caca06..32e1203 100644 --- a/template/hosts/darwins/minimal-darwin-system/home.nix +++ b/template/hosts/darwins/minimal-darwin-system/home.nix @@ -9,4 +9,6 @@ in home.packages = with soxincfg.packages."${pkgs.system}"; singleton helloSh; programs.zsh.enable = true; + + home.stateVersion = "23.05"; } diff --git a/template/hosts/nixoses/minimal-nixos-system/home.nix b/template/hosts/nixoses/minimal-nixos-system/home.nix index 802cc04..a92f8b5 100644 --- a/template/hosts/nixoses/minimal-nixos-system/home.nix +++ b/template/hosts/nixoses/minimal-nixos-system/home.nix @@ -9,4 +9,6 @@ in home.packages = with soxincfg.packages."${pkgs.system}"; singleton helloSh; programs.zsh.enable = true; + + home.stateVersion = "23.05"; } From e7f94bd0ff28dba1e783c1c65966f4cfcdba2ae6 Mon Sep 17 00:00:00 2001 From: Wael Nasreddine Date: Tue, 29 Aug 2023 23:26:39 -0700 Subject: [PATCH 40/41] enable zsh and set system state version --- template/hosts/nixoses/minimal-nixos-system/configuration.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/template/hosts/nixoses/minimal-nixos-system/configuration.nix b/template/hosts/nixoses/minimal-nixos-system/configuration.nix index 1167eba..d1cff4f 100644 --- a/template/hosts/nixoses/minimal-nixos-system/configuration.nix +++ b/template/hosts/nixoses/minimal-nixos-system/configuration.nix @@ -12,9 +12,13 @@ in soxincfg.nixosModules.profiles.workstation.nixos.local ]; + programs.zsh.enable = true; + # the user nick is created by the core profiles which is automatically added # to the configuration of all supported systems. home-manager.users.nick = { ... }: { imports = singleton ./home.nix; }; + + system.stateVersion = "23.05"; } From 75cc5559c6d3609aa0e884388929f00901d19f8d Mon Sep 17 00:00:00 2001 From: Wael Nasreddine Date: Tue, 29 Aug 2023 23:39:29 -0700 Subject: [PATCH 41/41] fmt tree --- lib/home-manager-configuration.nix | 32 +++++++++++++++--------------- template/hosts/darwins/default.nix | 10 +++++----- template/hosts/nixoses/default.nix | 10 +++++----- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/home-manager-configuration.nix b/lib/home-manager-configuration.nix index d174fbe..be234ae 100644 --- a/lib/home-manager-configuration.nix +++ b/lib/home-manager-configuration.nix @@ -39,21 +39,21 @@ let in home-manager.lib.homeManagerConfiguration (recursiveUpdate - { - extraSpecialArgs = { - inherit inputs soxin soxincfg; - - mode = "home-manager"; - } - # include the home-manager special arguments. - // hmSpecialArgs; - - extraModules = - # include the home-manager modules - hmModules - # include Soxin module - ++ (singleton soxin.nixosModules.soxin) - # include SoxinCFG module - ++ (singleton soxincfg.nixosModules.soxincfg); +{ + extraSpecialArgs = { + inherit inputs soxin soxincfg; + + mode = "home-manager"; } + # include the home-manager special arguments. + // hmSpecialArgs; + + extraModules = + # include the home-manager modules + hmModules + # include Soxin module + ++ (singleton soxin.nixosModules.soxin) + # include SoxinCFG module + ++ (singleton soxincfg.nixosModules.soxincfg); +} otherArguments) diff --git a/template/hosts/darwins/default.nix b/template/hosts/darwins/default.nix index bc2be04..d08aab3 100644 --- a/template/hosts/darwins/default.nix +++ b/template/hosts/darwins/default.nix @@ -14,11 +14,11 @@ let in mapAttrs (n: v: recursiveUpdate - { - inherit - mode - ; - } + { + inherit + mode + ; + } v) { ### diff --git a/template/hosts/nixoses/default.nix b/template/hosts/nixoses/default.nix index 082c73e..065c3bb 100644 --- a/template/hosts/nixoses/default.nix +++ b/template/hosts/nixoses/default.nix @@ -14,11 +14,11 @@ let in mapAttrs (n: v: recursiveUpdate - { - inherit - mode - ; - } + { + inherit + mode + ; + } v) { ###