diff --git a/Justfile b/Justfile index 769b712..4f5a40c 100755 --- a/Justfile +++ b/Justfile @@ -2,6 +2,9 @@ FLAKE_HOME := justfile_directory() DEFAULT_SPECIALISATION := "default" +DEFAULT_KEEP_SINCE := "1w" +DEFAULT_USER := env('USER') +DEFAULT_HOST := shell('hostname') default: @just --list @@ -18,15 +21,27 @@ build specialisation=DEFAULT_SPECIALISATION: deploy host: deploy {{ FLAKE_HOME }}#{{ host }} -clean keep_since="1w": - nh clean all --verbose -K {{ keep_since }} -k 5 +clean keepSince=DEFAULT_KEEP_SINCE: + nh clean all --verbose -K {{ keepSince }} -k 5 health: nix --accept-flake-config run github:juspay/nix-health +switchHome host=DEFAULT_HOST $USER=DEFAULT_USER: + @echo USER: $USER + @echo HOST: {{ host }} + nh home switch -b backup {{ if host != DEFAULT_HOST { "-c \"" + USER + "@" + host + "\"" } else { "" } }} {{ FLAKE_HOME }} + +buildHome host=DEFAULT_HOST $USER=DEFAULT_USER: + @echo USER: $USER + @echo HOST: {{ host }} + nh home build -b backup {{ if host != DEFAULT_HOST { "-c \"" + USER + "@" + host + "\"" } else { "" } }} {{ FLAKE_HOME }} + alias s := switch alias u := update alias d := deploy alias c := clean alias h := health alias b := build +alias H := switchHome +alias B := buildHome diff --git a/flake.nix b/flake.nix index 7e305eb..25a8388 100644 --- a/flake.nix +++ b/flake.nix @@ -183,15 +183,15 @@ pkgs = nixpkgs.legacyPackages."${system}"; modules = [ - (./home + "/${unixName}/configurations/${hostName}") + "${toString ./home}/${unixName}/configurations/${hostName}" ] ++ (with outputs.homeManagerModules; [ default - "${unixName}" + extra ]) - ++ (with inputs; [ - stylix.homeManagerModules.stylix - ]); + ++ [ + outputs.homeManagerModules."${unixName}" + ]; extraSpecialArgs = { inherit inputs @@ -220,18 +220,26 @@ homeManagerModules = { default = import ./home/modules; + extra = import ./home/extra; } // ( let allEntries = builtins.readDir ./home; allUsers = nixpkgs.lib.filterAttrs ( - key: value: value == "directory" && key != "modules" + key: value: + value == "directory" + && ( + !builtins.elem key [ + "modules" + "extra" + ] + ) ) allEntries; in builtins.listToAttrs ( map (name: { name = name; - value = import (./home + "/${name}/modules"); + value = import "${toString ./home}/${name}/modules"; }) (builtins.attrNames allUsers) ) ); diff --git a/home/extra/default.nix b/home/extra/default.nix new file mode 100644 index 0000000..fb437ca --- /dev/null +++ b/home/extra/default.nix @@ -0,0 +1,11 @@ +{ inputs, ... }: +{ + imports = + (with inputs; [ + niri-flake.homeModules.niri + stylix.homeManagerModules.stylix + ]) + ++ [ + ./nix.nix + ]; +} diff --git a/home/extra/nix.nix b/home/extra/nix.nix new file mode 100644 index 0000000..16fea1c --- /dev/null +++ b/home/extra/nix.nix @@ -0,0 +1,46 @@ +{ + outputs, + lib, + pkgs, + inputs, + ... +}: +{ + config = { + nixpkgs = { + config = { + allowUnfree = true; + allowUnfreePredicate = (_: true); + }; + overlays = [ + outputs.overlays.modifications + outputs.overlays.additions + ]; + }; + nix = { + package = pkgs.nix; + settings = { + inherit (outputs.nix.settings) substituters; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + "cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE=" + ]; + auto-optimise-store = lib.mkDefault true; + experimental-features = [ + "nix-command" + "flakes" + ]; + warn-dirty = false; + use-xdg-base-directories = true; + }; + registry.home = lib.mkDefault { + from = { + type = "indirect"; + id = "home"; + }; + flake = inputs.nixpkgs; + }; + }; + }; +} diff --git a/home/modules/default.nix b/home/modules/default.nix index a2aa712..d4fca85 100644 --- a/home/modules/default.nix +++ b/home/modules/default.nix @@ -1,6 +1,5 @@ { inputs, - lib, ... }: { @@ -9,21 +8,10 @@ sops-nix.homeManagerModules.sops ]) ++ [ - ./nix.nix ./programs ./xdg-dirs.nix ]; - options = { - youthlic.nixos.enable = lib.mkOption { - type = lib.types.bool; - default = false; - example = true; - description = '' - whether the os is nixos - ''; - }; - }; config = { programs.direnv = { enable = true; diff --git a/home/modules/nix.nix b/home/modules/nix.nix deleted file mode 100644 index 86a2de8..0000000 --- a/home/modules/nix.nix +++ /dev/null @@ -1,51 +0,0 @@ -{ - inputs, - lib, - config, - pkgs, - outputs, - ... -}: -{ - config = - let - cfg = config.youthlic.nixos; - in - (lib.mkIf (!cfg.enable) { - nixpkgs = { - config = { - allowUnfree = true; - allowUnfreePredicate = (_: true); - }; - overlays = [ - outputs.overlays.modifications - outputs.overlays.additions - ]; - }; - nix = { - package = pkgs.nix; - settings = { - inherit (outputs.nix.settings) substituters; - trusted-public-keys = [ - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" - "cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE=" - ]; - auto-optimise-store = lib.mkDefault true; - experimental-features = [ - "nix-command" - "flakes" - ]; - warn-dirty = false; - use-xdg-base-directories = true; - }; - registry.home = lib.mkDefault { - from = { - type = "indirect"; - id = "home"; - }; - flake = inputs.nixpkgs; - }; - }; - }); -} diff --git a/nixos/modules/home.nix b/nixos/modules/home.nix index 644ee18..638c072 100644 --- a/nixos/modules/home.nix +++ b/nixos/modules/home.nix @@ -50,10 +50,6 @@ outputs.homeManagerModules."${unixName}" (rootPath + "/home/${unixName}/configurations/${hostName}") ]; - - config = { - youthlic.nixos.enable = true; - }; } ); extraSpecialArgs = {