diff --git a/README.md b/README.md index 1eeef3b4..e8930f8e 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,10 @@ Also known as [盆栽(bonsai)](https://en.wikipedia.org/wiki/Bonsai) 🌳 ```bash nix run 'github:kachick/dotfiles#home-manager' -- switch -b backup --flake 'github:kachick/dotfiles#kachick' ``` +1. Make shells installed by nix into a login shell + ```bash + nix run 'github:kachick/dotfiles#sudo_enable_nix_login_shells' + ``` 1. If you have any problems with the installation steps, check both the [CI](.github/workflows/ci-home.yml) and the [wiki](https://github.com/kachick/dotfiles/wiki) and update them. 1. If you are developing this repository, the simple reactivation is as follows. ```bash diff --git a/flake.nix b/flake.nix index a0755d8b..fdbd041a 100644 --- a/flake.nix +++ b/flake.nix @@ -64,6 +64,28 @@ }; }; + packages.enable_nix_login_shells = pkgs.stdenv.mkDerivation + { + name = "enable_nix_login_shells"; + src = self; + buildInputs = with pkgs; [ + go_1_21 + ]; + buildPhase = '' + # https://github.com/NixOS/nix/issues/670#issuecomment-1211700127 + export HOME=$(pwd) + go build -o dist/enable_nix_login_shells ./cmd/enable_nix_login_shells + ''; + installPhase = '' + mkdir -p $out/bin + install -t $out/bin dist/enable_nix_login_shells + ''; + }; + + packages.sudo_enable_nix_login_shells = pkgs.writeScriptBin "sudo_enable_nix_login_shells" '' + sudo -E ${packages.enable_nix_login_shells}/bin/enable_nix_login_shells + ''; + # https://gist.github.com/Scoder12/0538252ed4b82d65e59115075369d34d?permalink_comment_id=4650816#gistcomment-4650816 packages.json2nix = pkgs.writeScriptBin "json2nix" '' ${pkgs.python3}/bin/python ${pkgs.fetchurl { @@ -79,6 +101,11 @@ drv = home-manager.defaultPackage.${system}; }; + sudo_enable_nix_login_shells = { + type = "app"; + program = "${packages.sudo_enable_nix_login_shells}/bin/sudo_enable_nix_login_shells"; + }; + # example: `nix run .#json2nix gitconfig.json` json2nix = { type = "app";