From 99f0311a38fec6f2a59127bbc3e2b5022d7c80c0 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Tue, 21 Jan 2025 23:31:00 -0700 Subject: [PATCH] Fix error around --impure I was seeing a stack trace with this at the bottom: error: cannot look up '' in pure evaluation mode (use '--impure' to override) After reading a bit at https://nixos-and-flakes.thiscute.world/nixos-with-flakes/start-using-home-manager I was able to craft this shape which uses home-manager in a flake and doesn't have the same problem. --- sovr/etc/nixos/configuration.nix | 11 ----------- sovr/etc/nixos/flake.lock | 30 ++++++++++++++++++++++++++---- sovr/etc/nixos/flake.nix | 12 +++++++++++- sovr/etc/nixos/home.nix | 10 ++++++++++ 4 files changed, 47 insertions(+), 16 deletions(-) create mode 100644 sovr/etc/nixos/home.nix diff --git a/sovr/etc/nixos/configuration.nix b/sovr/etc/nixos/configuration.nix index 7102720..4f15581 100644 --- a/sovr/etc/nixos/configuration.nix +++ b/sovr/etc/nixos/configuration.nix @@ -8,8 +8,6 @@ imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - # Include the home-manager configuration - inputs.sovr.nixosModules.default ]; @@ -31,15 +29,6 @@ inputs.sovr.packages."${pkgs.system}".sovr-server ]; - home-manager.useGlobalPkgs = true; - home-manager.users.eliribble = { - home.file.".config/nvim/after/ftplugin/html.vim".source = ./home/eliribble/config/nvim/after/ftplugin/html.vim; - home.file.".config/nvim/after/ftplugin/go.vim".source = ./home/eliribble/config/nvim/after/ftplugin/go.vim; - home.file.".config/tmux/tmux.conf".source = ./home/eliribble/config/tmux/tmux.conf; - home.homeDirectory = "/home/eliribble"; - home.stateVersion = "24.11"; - home.username = "eliribble"; - }; i18n.defaultLocale = "en_US.UTF-8"; networking = { diff --git a/sovr/etc/nixos/flake.lock b/sovr/etc/nixos/flake.lock index b09fe6f..c44bd53 100644 --- a/sovr/etc/nixos/flake.lock +++ b/sovr/etc/nixos/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1736373539, + "narHash": "sha256-dinzAqCjenWDxuy+MqUQq0I4zUSfaCvN9rzuCmgMZJY=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "bd65bc3cde04c16755955630b344bc9e35272c56", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-24.11", + "repo": "home-manager", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1735264675, @@ -34,6 +55,7 @@ }, "root": { "inputs": { + "home-manager": "home-manager", "nixpkgs": "nixpkgs", "sovr": "sovr" } @@ -43,11 +65,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1735827455, - "narHash": "sha256-BpqQu/opMGrr6xUbbFQy2bkEbUSQhbxN4X8M8DRun5I=", + "lastModified": 1735922336, + "narHash": "sha256-pccBDqwpLTT24mwQTfLxDciSMg95FPhVy683FvUpkj4=", "ref": "refs/heads/main", - "rev": "950e618c387282e13e4ec865ae37d0e168b4469a", - "revCount": 60, + "rev": "85fc0509c232e4073896de480a4dec94bb97547c", + "revCount": 64, "type": "git", "url": "file:///home/eliribble/src/sovr.cloud" }, diff --git a/sovr/etc/nixos/flake.nix b/sovr/etc/nixos/flake.nix index a865907..bcdc50b 100644 --- a/sovr/etc/nixos/flake.nix +++ b/sovr/etc/nixos/flake.nix @@ -3,11 +3,15 @@ inputs = { # NixOS official package source, using the nixos-24.11 branch here + home-manager = { + url = "github:nix-community/home-manager/release-24.11"; + inputs.nixpkgs.follows = "nixpkgs"; + }; nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; sovr.url = "git+file:///home/eliribble/src/sovr.cloud"; }; - outputs = { self, nixpkgs, sovr, ... }@inputs: { + outputs = { self, home-manager, nixpkgs, sovr, ... }@inputs: { nixosConfigurations.sovr = nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs; }; system = "x86_64-linux"; @@ -15,6 +19,12 @@ # Import the previous configuration.nix we used, # so the old configuration file still takes effect ./configuration.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.eliribble = import ./home.nix; + } ]; }; }; diff --git a/sovr/etc/nixos/home.nix b/sovr/etc/nixos/home.nix new file mode 100644 index 0000000..68365ad --- /dev/null +++ b/sovr/etc/nixos/home.nix @@ -0,0 +1,10 @@ + { config, pkgs, ... }: + + { + home.file.".config/nvim/after/ftplugin/html.vim".source = ./home/eliribble/config/nvim/after/ftplugin/html.vim; + home.file.".config/nvim/after/ftplugin/go.vim".source = ./home/eliribble/config/nvim/after/ftplugin/go.vim; + home.file.".config/tmux/tmux.conf".source = ./home/eliribble/config/tmux/tmux.conf; + home.homeDirectory = "/home/eliribble"; + home.stateVersion = "24.11"; + home.username = "eliribble"; + }