From ee6a735a2c3ae69622e6e01d849802d23bb16b84 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 21 Feb 2023 17:24:18 +0000 Subject: [PATCH 1/2] home: add nix This is basically the same thing as the NixOS module, except for NIX_PATH handling [1]. [1]: https://github.com/nix-community/home-manager/pull/2677 --- home/default.nix | 1 + home/nix/default.nix | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 home/nix/default.nix diff --git a/home/default.nix b/home/default.nix index 82d2cc3..3e34ddb 100644 --- a/home/default.nix +++ b/home/default.nix @@ -19,6 +19,7 @@ ./jq ./mail ./mpv + ./nix ./nix-index ./nm-applet ./packages diff --git a/home/nix/default.nix b/home/nix/default.nix new file mode 100644 index 0000000..a846baa --- /dev/null +++ b/home/nix/default.nix @@ -0,0 +1,39 @@ +# Nix related settings +{ config, inputs, lib, options, pkgs, ... }: +let + cfg = config.my.home.nix; +in +{ + options.my.home.nix = with lib; { + enable = my.mkDisableOption "nix configuration"; + + addToRegistry = my.mkDisableOption "add inputs and self to registry"; + + overrideNixpkgs = my.mkDisableOption "point nixpkgs to pinned system version"; + }; + + config = lib.mkIf cfg.enable (lib.mkMerge [ + { + nix = { + package = lib.mkDefault pkgs.nix; + + settings = { + experimental-features = [ "nix-command" "flakes" ]; + }; + }; + } + + (lib.mkIf cfg.addToRegistry { + nix.registry = { + # Allow me to use my custom package using `nix run self#pkg` + self.flake = inputs.self; + # Use pinned nixpkgs when using `nix run pkgs#` + pkgs.flake = inputs.nixpkgs; + # ... And also with `nix run nixpkgs#` + nixpkgs.flake = lib.mkIf cfg.overrideNixpkgs inputs.nixpkgs; + # Add NUR to run some packages that are only present there + nur.flake = inputs.nur; + }; + }) + ]); +} From 737747f8f5ce4fb1c3c0cf700390a77166f1f214 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 21 Feb 2023 17:23:36 +0000 Subject: [PATCH 2/2] flake: add 'homeConfigurations.ambroisie' --- flake.nix | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/flake.nix b/flake.nix index 6d329bd..75aea21 100644 --- a/flake.nix +++ b/flake.nix @@ -165,6 +165,39 @@ ambroisie = prev.recurseIntoAttrs (import ./pkgs { pkgs = prev; }); }; }; + homeConfigurations = + let + system = "x86_64-linux"; + pkgs = import nixpkgs { + inherit system; + overlays = (lib.attrValues self.overlays) ++ [ + nur.overlay + ]; + }; + in + { + ambroisie = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + + modules = [ + ./home + { + # The basics + home.username = "ambroisie"; + home.homeDirectory = "/home/ambroisie"; + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + # This is a generic linux install + targets.genericLinux.enable = true; + } + ]; + + extraSpecialArgs = { + # Inject inputs to use them in global registry + inherit inputs; + }; + }; + }; nixosConfigurations = lib.mapAttrs buildHost { aramis = "x86_64-linux";