diff --git a/.gitignore b/.gitignore index d248ca6..58b61a1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ !machines/asus/git/ !machines/asus/neovim/ !machines/asus/neovim/config/ +!machines/asus/neovim/nvchad/ !machines/asus/networkmanager/ !machines/asus/nixpkgs/ !machines/asus/nushell/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..7777fcf --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "./machines/asus/neovim/nvchad"] +path = ./machines/asus/neovim/nvchad +url = https://github.com/RGBCube/NvChad diff --git a/flake.nix b/flake.nix index ef354bf..7592ced 100644 --- a/flake.nix +++ b/flake.nix @@ -46,10 +46,26 @@ overlays = [fenix.overlays.default]; }; - # Helper function for DRY. + # Helper functiona for DRY. homeManagerConfiguration = userName: attrs: { home-manager.users.${userName} = attrs; }; + + homeManagerConfigurationWithArgs = userName: attrsFunc: { + home-manager.users.${userName} = args: attrsFunc args; + }; + + # Q: Can't we just do "./foo" ? + # A: When configuring our system with flakes, Nix copies them to the + # Nix store to run them. So we can't use relative paths as they will refer + # to a file which is in the Nix store, and is immutable because it is in + # the Nix store, which beats the point of abusing Home Managers + # mkOutOfStoreSymlink to create symlinks to mutable files. + # To avoid this, we must give an absolute path to a file, + # so we do this. The $PWD is replaced by the rebuild script + # with the working directory, then changed back after the build. + # And yes, this is a major hack. + projectPath = "@pwd@"; }; modules = [ diff --git a/machines/asus/neovim/default.nix b/machines/asus/neovim/default.nix index e96ed15..c7ccdb1 100644 --- a/machines/asus/neovim/default.nix +++ b/machines/asus/neovim/default.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, homeManagerConfiguration, ... }: +{ pkgs, lib, homeManagerConfigurationWithArgs, projectPath, ... }: { # Nuking nano out of orbit. @@ -8,7 +8,7 @@ // -(homeManagerConfiguration "nixos" { +(homeManagerConfigurationWithArgs "nixos" ({ config, ... }: { programs.neovim.enable = true; programs.neovim = { defaultEditor = true; @@ -19,13 +19,6 @@ # NvChad home.file.".config/nvim" = { - source = pkgs.callPackage ../../../packages/nvchad {}; - recursive = true; + source = config.lib.file.mkOutOfStoreSymlink projectPath + "/machines/asus/neovim/nvchad"; }; - - home.file.".config/nvim/lua/custom" = { - source = ./config; - recursive = true; - force = true; - }; -}) +})) diff --git a/machines/asus/neovim/nvchad b/machines/asus/neovim/nvchad new file mode 160000 index 0000000..3dd0fa6 --- /dev/null +++ b/machines/asus/neovim/nvchad @@ -0,0 +1 @@ +Subproject commit 3dd0fa6c5b0933d9a395e2492de69c151831c66e diff --git a/rebuild.sh b/rebuild.sh index 217a858..7de126d 100755 --- a/rebuild.sh +++ b/rebuild.sh @@ -19,12 +19,17 @@ else read -p "What machine would you want to build? [$(ls --format=commas machines)]: " machine fi -sudo nixos-rebuild switch --flake .#$machine +sed -ie "s|@pwd@|$PWD|g" flake.nix +sudo nixos-rebuild switch --impure --flake .#$machine if [[ $? != 0 ]]; then exit 1 fi +sed -ie "s|$PWD|@pwd@|g" flake.nix +# No clue how to prevent sed from outputting this. +rm flake.nixe + if [[ $1 != "-c" && $1 != "--clean-garbage" ]]; then read -p "Clean garbage? [Y/N]: " clean_garbage