From a0a94b86ffe3ec317ada5726acff16398a4e992f Mon Sep 17 00:00:00 2001 From: Katherina Walshe-Grey Date: Thu, 12 Sep 2024 12:56:30 +0100 Subject: [PATCH 1/3] home-manager: rearrange config --- common/home-manager.nix | 12 ++++-------- common/users/qenya.nix | 5 +++++ flake.nix | 14 ++++---------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/common/home-manager.nix b/common/home-manager.nix index e4d7106..171a382 100644 --- a/common/home-manager.nix +++ b/common/home-manager.nix @@ -1,13 +1,9 @@ { config, lib, pkgs, ... }: { - home-manager.users = { - qenya = { config, lib, pkgs, osConfig, ... }: { - home.homeDirectory = osConfig.users.users.qenya.home; - - imports = [ - ../home/qenya - ]; - }; + home-manager = { + useUserPackages = true; + useGlobalPkgs = true; + backupFileExtension = "backup"; }; } diff --git a/common/users/qenya.nix b/common/users/qenya.nix index e9d11ad..19dc8ed 100644 --- a/common/users/qenya.nix +++ b/common/users/qenya.nix @@ -11,4 +11,9 @@ in { }; programs.zsh.enable = true; + + home-manager.users.qenya = { config, lib, pkgs, osConfig, ... }: { + home.homeDirectory = osConfig.users.users.qenya.home; + imports = [ ../../home/qenya ]; + }; } diff --git a/flake.nix b/flake.nix index 9746dec..232dbf7 100644 --- a/flake.nix +++ b/flake.nix @@ -43,17 +43,11 @@ nixpkgs.config.allowUnfree = true; nixpkgs.config.packageOverrides = pkgs: { - agenix = inputs.agenix.packages.${config.nixpkgs.hostPlatform.system}.default; - rc2nix = inputs.plasma-manager.packages.${config.nixpkgs.hostPlatform.system}.rc2nix; - }; - nixpkgs.overlays = [ inputs.nur.overlay ]; - - home-manager = { - useUserPackages = true; - useGlobalPkgs = true; - backupFileExtension = "backup"; - sharedModules = [ plasma-manager.homeManagerModules.plasma-manager ]; + agenix = agenix.packages.${config.nixpkgs.hostPlatform.system}.default; + rc2nix = plasma-manager.packages.${config.nixpkgs.hostPlatform.system}.rc2nix; }; + nixpkgs.overlays = [ nur.overlay ]; + home-manager.sharedModules = [ plasma-manager.homeManagerModules.plasma-manager ]; imports = [ home-manager.nixosModules.home-manager From 4a9e6b5f3ca2bd9685d0474e178890cd6e0be352 Mon Sep 17 00:00:00 2001 From: Katherina Walshe-Grey Date: Thu, 12 Sep 2024 13:35:35 +0100 Subject: [PATCH 2/3] move tooling to dev environment --- common/environment.nix | 5 ----- flake.nix | 18 ++++++++++++++---- shell.nix | 9 +++++++++ 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 shell.nix diff --git a/common/environment.nix b/common/environment.nix index 122e2f5..384e88d 100644 --- a/common/environment.nix +++ b/common/environment.nix @@ -12,11 +12,6 @@ lsof tcpdump netcat # <3 - - # used for nix config - colmena - agenix - rc2nix ]; environment.wordlist.enable = true; diff --git a/flake.nix b/flake.nix index 232dbf7..7f3b793 100644 --- a/flake.nix +++ b/flake.nix @@ -42,10 +42,6 @@ nix.nixPath = [ "nixpkgs=flake:nixpkgs" ]; nixpkgs.config.allowUnfree = true; - nixpkgs.config.packageOverrides = pkgs: { - agenix = agenix.packages.${config.nixpkgs.hostPlatform.system}.default; - rc2nix = plasma-manager.packages.${config.nixpkgs.hostPlatform.system}.rc2nix; - }; nixpkgs.overlays = [ nur.overlay ]; home-manager.sharedModules = [ plasma-manager.homeManagerModules.plasma-manager ]; @@ -92,5 +88,19 @@ ]; }; }; + + # TODO: have this work on other systems too + devShells."x86_64-linux".default = + let + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; }; + in + pkgs.mkShell { + packages = [ + pkgs.colmena + agenix.packages.${system}.default + plasma-manager.packages.${system}.rc2nix + ]; + }; }; } diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..688ef15 --- /dev/null +++ b/shell.nix @@ -0,0 +1,9 @@ +let + shell = (import + (fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/refs/tags/v1.0.1.tar.gz"; + sha256 = "0jm6nzb83wa6ai17ly9fzpqc40wg1viib8klq8lby54agpl213w5"; + }) + { src = ./.; }).shellNix; +in +shell.devShells.${builtins.currentSystem} From 752fce2538a1f82abe977e29354612dc0ca59341 Mon Sep 17 00:00:00 2001 From: Katherina Walshe-Grey Date: Thu, 12 Sep 2024 13:55:15 +0100 Subject: [PATCH 3/3] qenya: zsh: automatically run nix-shell when necessary Closes #9 --- home/qenya/zsh.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/home/qenya/zsh.nix b/home/qenya/zsh.nix index f6ded78..42ccf8f 100644 --- a/home/qenya/zsh.nix +++ b/home/qenya/zsh.nix @@ -25,6 +25,15 @@ theme = "agnoster"; }; + initExtra = '' + # If a shell is started in a directory with a shell.nix, automatically run nix-shell + if [ -f ./shell.nix ]; then + if [ -z "$IN_NIX_SHELL" ]; then + nix-shell --command "zsh" + fi + fi + ''; + envExtra = '' DEFAULT_USER=qenya '';