From 2d10939285f4c9ffb3858d42896592c0c14b3fb9 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 30 Oct 2022 20:14:41 -0400 Subject: [PATCH] clean up flake inputs and allow standalone home-manager closes #11 --- flake.nix | 30 +++++++++++++++++------------- hosts/aws/default.nix | 4 +++- hosts/desktop/default.nix | 4 +++- hosts/macbook/default.nix | 4 +++- hosts/oracle/default.nix | 4 +++- hosts/wsl/default.nix | 4 +++- modules/darwin/nixpkgs.nix | 7 +++++++ modules/shell/nixpkgs.nix | 8 ++++++++ 8 files changed, 47 insertions(+), 18 deletions(-) diff --git a/flake.nix b/flake.nix index 09b8e3c..d588a57 100644 --- a/flake.nix +++ b/flake.nix @@ -61,27 +61,31 @@ # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. forAllSystems = nixpkgs.lib.genAttrs supportedSystems; - in { + in rec { - nixosConfigurations = with inputs; { - desktop = import ./hosts/desktop { - inherit nixpkgs home-manager nur globals wallpapers; - }; - wsl = import ./hosts/wsl { inherit nixpkgs wsl home-manager globals; }; - oracle = - import ./hosts/oracle { inherit nixpkgs home-manager globals; }; + nixosConfigurations = { + desktop = import ./hosts/desktop { inherit inputs globals; }; + wsl = import ./hosts/wsl { inherit inputs globals; }; + oracle = import ./hosts/oracle { inherit inputs globals; }; }; - darwinConfigurations = with inputs; { - macbook = import ./hosts/macbook { - inherit nixpkgs darwin home-manager nur globals; - }; + darwinConfigurations = { + macbook = import ./hosts/macbook { inherit inputs globals; }; + }; + + # For quickly applying local settings with: + # home-manager switch --flake .#desktop + homeConfigurations = { + desktop = + nixosConfigurations.desktop.config.home-manager.users.${globals.user}.home; + macbook = + darwinConfigurations.macbook.config.home-manager.users."Noah.Masur".home; }; # Package servers into images with a generator packages.x86_64-linux = with inputs; { aws = import ./hosts/aws { - inherit nixpkgs nixos-generators home-manager globals; + inherit inputs globals; system = "x86_64-linux"; }; }; diff --git a/hosts/aws/default.nix b/hosts/aws/default.nix index 69bf62c..036679f 100644 --- a/hosts/aws/default.nix +++ b/hosts/aws/default.nix @@ -1,4 +1,6 @@ -{ nixpkgs, system, nixos-generators, home-manager, globals, ... }: +{ inputs, globals, ... }: + +with inputs; nixos-generators.nixosGenerate { inherit system; diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index bc771e4..198e910 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -1,4 +1,6 @@ -{ nixpkgs, home-manager, nur, globals, wallpapers, ... }: +{ inputs, globals, ... }: + +with inputs; # System configuration for my desktop nixpkgs.lib.nixosSystem { diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix index 8d3dcf4..828c732 100644 --- a/hosts/macbook/default.nix +++ b/hosts/macbook/default.nix @@ -1,4 +1,6 @@ -{ nixpkgs, darwin, home-manager, nur, globals, ... }: +{ inputs, globals, ... }: + +with inputs; # System configuration for my work MacBook darwin.lib.darwinSystem { diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index fe13e85..25fa460 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -1,4 +1,6 @@ -{ nixpkgs, home-manager, globals, ... }: +{ inputs, globals, ... }: + +with inputs; # System configuration for an Oracle free server diff --git a/hosts/wsl/default.nix b/hosts/wsl/default.nix index 95cc9f3..2c700b4 100644 --- a/hosts/wsl/default.nix +++ b/hosts/wsl/default.nix @@ -1,4 +1,6 @@ -{ nixpkgs, wsl, home-manager, globals, ... }: +{ inputs, globals, ... }: + +with inputs; # System configuration for WSL nixpkgs.lib.nixosSystem { diff --git a/modules/darwin/nixpkgs.nix b/modules/darwin/nixpkgs.nix index 3f8fbc1..b3e69ce 100644 --- a/modules/darwin/nixpkgs.nix +++ b/modules/darwin/nixpkgs.nix @@ -18,6 +18,13 @@ commandline --function execute ''; }; + rebuild-home = lib.mkForce { + body = '' + git -C ${config.dotfilesPath} add --intent-to-add --all + commandline -r ${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName}"; + commandline --function execute + ''; + }; }; }; diff --git a/modules/shell/nixpkgs.nix b/modules/shell/nixpkgs.nix index bb2096f..e6a1840 100644 --- a/modules/shell/nixpkgs.nix +++ b/modules/shell/nixpkgs.nix @@ -12,6 +12,7 @@ nixh = "man home-configuration.nix"; nr = "rebuild-nixos"; nro = "rebuild-nixos offline"; + hm = "rebuild-home"; }; functions = { nix-shell-run = { @@ -43,6 +44,13 @@ commandline --function execute ''; }; + rebuild-home = { + body = '' + git -C ${config.dotfilesPath} add --intent-to-add --all + commandline -r "${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName}"; + commandline --function execute + ''; + }; }; };