From d4afb26bd1ed30053b383ee30704b84c808ead3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Mon, 2 Jun 2025 17:53:48 +0200 Subject: [PATCH] feat: add a home-manager example configuration This adds a home-manager example configuration to ensure the home-manager standalone module works properly. --- .forgejo/workflows/check.yml | 12 ++++++ example-hm/home.nix | 70 +++++++++++++++++++++++++++++++ flake-modules/default.nix | 2 +- flake-modules/example-configs.nix | 33 +++++++++++++++ flake-modules/example-vm.nix | 18 -------- 5 files changed, 116 insertions(+), 19 deletions(-) create mode 100644 example-hm/home.nix create mode 100644 flake-modules/example-configs.nix delete mode 100644 flake-modules/example-vm.nix diff --git a/.forgejo/workflows/check.yml b/.forgejo/workflows/check.yml index bcc845a..3199e04 100644 --- a/.forgejo/workflows/check.yml +++ b/.forgejo/workflows/check.yml @@ -66,10 +66,22 @@ jobs: - name: Build VM configuration run: | nix build --print-build-logs '.#nixosConfigurations.vm.config.system.build.toplevel' + build-hm: + runs-on: nixos + needs: + - build-package + - check-nvim + steps: + - uses: "https://git.salame.cl/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4 + - run: nix --version + - name: Build Home Manager configuration + run: | + nix build --print-build-logs '.#homeConfigurations.example.activationPackage' report-size: runs-on: nixos needs: - build-vm + - build-hm steps: - uses: "https://git.salame.cl/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4 - run: nix --version diff --git a/example-hm/home.nix b/example-hm/home.nix new file mode 100644 index 0000000..4e86064 --- /dev/null +++ b/example-hm/home.nix @@ -0,0 +1,70 @@ +{ + lib, + pkgs, + config, + ... +}: +{ + home = { + homeDirectory = "/home/jdoe"; + stateVersion = "25.05"; + username = "jdoe"; + }; + + jhome = { + enable = true; + dev = { + enable = true; + neovimAsManPager = true; + rust.enable = true; + }; + gui.enable = false; + hostName = "example"; + user = { + enable = true; + defaultIdentity = { + email = "jdoe@example.org"; + name = "John Doe"; + }; + }; + }; + + programs = { + # Switch to fish if bash is started interactively + bash.initExtra = '' + if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]] + then + shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION="" + exec ${pkgs.fish}/bin/fish $LOGIN_OPTION + fi + ''; + + # Enable zellij (tmux like terminal session manager) + zellij.enable = lib.mkForce true; + }; + + nix = { + package = pkgs.lix; + gc = { + automatic = true; + frequency = "weekly"; + options = "--delete-older-than 30d"; + # run between 0 and 45min after boot if run was missed + randomizedDelaySec = "45min"; + }; + settings = { + # Add my personal binary cache to the mix (only for personal computers) + extra-substituters = [ "https://cache.salame.cl" ]; + extra-trusted-public-keys = [ "cache.salame.cl:D+pBaoutwxja7qKGpju+CmM1LRbVmf2gqEQ/9c7qHrw=" ]; + auto-optimise-store = true; + }; + }; + + stylix = { + image = config.jhome.gui.sway.background; + base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml"; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +} diff --git a/flake-modules/default.nix b/flake-modules/default.nix index d793f21..1b806a6 100644 --- a/flake-modules/default.nix +++ b/flake-modules/default.nix @@ -5,7 +5,7 @@ ./devshells.nix ./docs.nix - ./example-vm.nix + ./example-configs.nix ./nixos-modules.nix ./home-modules.nix ./nixvim-modules.nix diff --git a/flake-modules/example-configs.nix b/flake-modules/example-configs.nix new file mode 100644 index 0000000..362e36a --- /dev/null +++ b/flake-modules/example-configs.nix @@ -0,0 +1,33 @@ +{ inputs, lib, ... }: +{ + flake = { + # Example vm configuration + nixosConfigurations.vm = lib.nixosSystem { + modules = [ + inputs.self.nixosModules.default + ../example-vm # import vm configuration + { + nixpkgs = { + overlays = builtins.attrValues inputs.self.overlays; + config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "steam-unwrapped" ]; + }; + # pin nixpkgs to the one used by the system + nix.registry.nixpkgs.flake = inputs.nixpkgs; + } + ]; + }; + homeConfigurations.example = inputs.home-manager.lib.homeManagerConfiguration { + pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; + modules = [ + inputs.self.homeModules.standalone + ../example-hm/home.nix # import home-manager configuration + { + nixpkgs.overlays = [ + inputs.self.overlays.unstable + inputs.lix-module.overlays.default + ]; + } + ]; + }; + }; +} diff --git a/flake-modules/example-vm.nix b/flake-modules/example-vm.nix deleted file mode 100644 index e941b37..0000000 --- a/flake-modules/example-vm.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ inputs, lib, ... }: -{ - # Example vm configuration - flake.nixosConfigurations.vm = lib.nixosSystem { - modules = [ - inputs.self.nixosModules.default - ../example-vm # import vm configuration - { - nixpkgs = { - overlays = builtins.attrValues inputs.self.overlays; - config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "steam-unwrapped" ]; - }; - # pin nixpkgs to the one used by the system - nix.registry.nixpkgs.flake = inputs.nixpkgs; - } - ]; - }; -}