diff options
author | Baitinq <30861839+Baitinq@users.noreply.github.com> | 2022-08-28 22:11:24 +0000 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-08-29 00:11:24 +0200 |
commit | f4195828af618f3451b69a5c7ae09d2ecbdd5b72 (patch) | |
tree | ae04ae5afae4a599f06fe46cdb80beca54f27f18 | |
parent | Packages: Remove xmonadctl (diff) | |
download | nixos-config-f4195828af618f3451b69a5c7ae09d2ecbdd5b72.tar.gz nixos-config-f4195828af618f3451b69a5c7ae09d2ecbdd5b72.tar.bz2 nixos-config-f4195828af618f3451b69a5c7ae09d2ecbdd5b72.zip |
Implement non NixOS hosts support
Diffstat (limited to '')
-rw-r--r-- | README.md | 16 | ||||
-rw-r--r-- | flake.nix | 10 | ||||
-rw-r--r-- | hosts/default.nix | 46 |
3 files changed, 52 insertions, 20 deletions
diff --git a/README.md b/README.md index 1903ec7..aa1267d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # NIX Config My Personal NixOS Flake. + +# NixOS ## Installing ``` @@ -13,4 +15,16 @@ nixos-install --flake . #HOST nix flake update nixos-rebuild switch --flake . #HOST -``` \ No newline at end of file +``` + +# Non-Nixos +## Installing +``` +nix build .#homeManagerConfigurations.HOST.activationPackage +./result/activate +``` + +## Updating +``` +home-manager switch --flake .#HOST +``` diff --git a/flake.nix b/flake.nix index 7948fd6..f997fa2 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "My NixOS configuration"; + description = "My Nix(\"OS\" or \"\") configuration"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; @@ -28,6 +28,14 @@ outputs = inputs @ { self, nixpkgs, home-manager, ... }: { nixosConfigurations = import ./hosts { + isNixOS = true; + inherit (nixpkgs) lib; + inherit inputs nixpkgs home-manager; + }; + + homeConfigurations = import ./hosts { + isNixOS = false; + #no COde duplication here: TODO inherit (nixpkgs) lib; inherit inputs nixpkgs home-manager; }; diff --git a/hosts/default.nix b/hosts/default.nix index 9c23363..5ad2c85 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -1,4 +1,4 @@ -{ lib, nixpkgs, inputs, home-manager, ... }: +{ lib, inputs, isNixOS, nixpkgs, home-manager, ... }: let user = "baitinq"; @@ -10,7 +10,7 @@ let { hostname = "vm"; system = "x86_64-linux"; timezone = secrets.main_timezone; location = secrets.main_location; } ]; - mkHost = { hostname, system, timezone, location }: + mkHost = { hostname, system, timezone, location }: isNixOS: let pkgs = import nixpkgs { inherit system; @@ -23,27 +23,37 @@ let }; extraArgs = { inherit pkgs inputs user secrets hostname timezone location; }; in - nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = extraArgs; - modules = [ - ./configuration.nix - ./${hostname} - home-manager.nixosModules.home-manager + if isNixOS + then + nixpkgs.lib.nixosSystem { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = extraArgs; - home-manager.users.${user} = { - imports = [ ./home.nix ] ++ [ (import ./${ hostname }/home.nix) ]; - }; + inherit system; + specialArgs = extraArgs; + modules = [ + ./configuration.nix + ./${hostname} + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = extraArgs; + home-manager.users.${user} = { + imports = [ ./home.nix ] ++ [ (import ./${ hostname }/home.nix) ]; + }; + } + ]; } - ]; - }; + else + home-manager.lib.homeManagerConfiguration + { + inherit pkgs; + extraSpecialArgs = extraArgs; + modules = [ ./home.nix ] ++ [ (import ./${ hostname }/home.nix) ]; + }; in /* We have a list of sets. Map each element of the list applying the mkHost function to its elements and returning a set in the listToAttrs format builtins.listToAttrs on the result */ -builtins.listToAttrs (map ({ hostname, system, timezone, location }: { name = hostname; value = mkHost { inherit hostname system timezone location; }; }) hosts) +builtins.listToAttrs (map ({ hostname, system, timezone, location }: { name = hostname; value = mkHost { inherit hostname system timezone location; } isNixOS; }) hosts) |