From 7eb32cfabcb56b3bd64aa61a52e8afbe3c0a0248 Mon Sep 17 00:00:00 2001 From: imxyy_soope_ Date: Sun, 28 Dec 2025 10:47:21 +0800 Subject: [PATCH] feat: impure symlink --- .envrc | 1 + Makefile => Justfile | 19 ++++++++--------- lib/default.nix | 2 +- modules/coding/editor/neovim/default.nix | 8 +++----- modules/coding/misc.nix | 1 + modules/impure.nix | 26 ++++++++++++++++++++++++ 6 files changed, 41 insertions(+), 16 deletions(-) create mode 100644 .envrc rename Makefile => Justfile (78%) create mode 100644 modules/impure.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..9428f3c --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +export IMPURE_ROOT=$(pwd) diff --git a/Makefile b/Justfile similarity index 78% rename from Makefile rename to Justfile index ead411a..6f15483 100644 --- a/Makefile +++ b/Justfile @@ -1,28 +1,29 @@ +root := `pwd` +NH := "IMPURE_ROOT=" + root + " nh" + all: fmt switch switch: @echo "Rebuilding NixOS..." - @nh os switch . + @{{NH}} os switch . --impure switch-offline: @echo "Rebuilding NixOS without net..." - @nh os switch . --no-net + @{{NH}} os switch . --impure --no-net -offline: - @echo "Rebuilding NixOS without net..." - @nh os switch . --no-net +alias offline := switch-offline boot: @echo "Rebuilding NixOS..." - @nh os boot . + @{{NH}} os boot . --impure test: @echo "Rebuilding NixOS..." - @nh os test . + @{{NH}} os test . --impure vm: @echo "Building NixOS VM..." - @nh os build-vm . + @{{NH}} os build-vm . --impure update: @echo "Updating flakes..." @@ -47,5 +48,3 @@ gc: fmt: @echo "Formatting nix files..." @nix fmt - -.PHONY: all switch switch-offline boot test vm update repl cleandry clean gc fmt diff --git a/lib/default.nix b/lib/default.nix index 7ee789c..d8a7dbc 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,8 +1,8 @@ { lib, inputs }: lib.extend ( self: super: { - umport = import ./umport.nix { lib = self; }; inherit (inputs.home-manager.lib) hm; + umport = import ./umport.nix { lib = self; }; haumea = inputs.haumea.lib; infuse = (import inputs.infuse { inherit lib; }).v1.infuse; } diff --git a/modules/coding/editor/neovim/default.nix b/modules/coding/editor/neovim/default.nix index ffb3e12..7ed90bb 100644 --- a/modules/coding/editor/neovim/default.nix +++ b/modules/coding/editor/neovim/default.nix @@ -2,6 +2,7 @@ config, lib, pkgs, + impure, ... }: let @@ -14,11 +15,8 @@ in config = lib.mkIf cfg.enable { my.hm = { - xdg.configFile."nvim/init.lua".source = ./nvim/init.lua; - xdg.configFile."nvim/lua" = { - source = ./nvim/lua; - recursive = true; - }; + xdg.configFile."nvim/init.lua".source = impure.mkImpureLink ./nvim/init.lua; + xdg.configFile."nvim/lua".source = impure.mkImpureLink ./nvim/lua; programs.neovim = { enable = true; defaultEditor = true; diff --git a/modules/coding/misc.nix b/modules/coding/misc.nix index 89ea1bf..6c79cff 100644 --- a/modules/coding/misc.nix +++ b/modules/coding/misc.nix @@ -15,6 +15,7 @@ in config = lib.mkIf cfg.enable { my.hm = { home.packages = with pkgs; [ + just gnumake github-cli # gh ]; diff --git a/modules/impure.nix b/modules/impure.nix new file mode 100644 index 0000000..0b512db --- /dev/null +++ b/modules/impure.nix @@ -0,0 +1,26 @@ +{ + lib, + pkgs, + self, + ... +}: +let + relativePath = + path: + assert lib.types.path.check path; + lib.strings.removePrefix (toString self) (toString path); + mkImpureLink = + path: + let + relative = relativePath path; + in + pkgs.runCommandLocal relative { } "ln -s ${lib.escapeShellArg (impureRoot + relative)} $out"; + impureRoot = + let + impureRoot = builtins.getEnv "IMPURE_ROOT"; + in + if impureRoot == "" then throw "IMPURE_ROOT is not set" else impureRoot; +in +{ + _module.args.impure = { inherit mkImpureLink; }; +}