Skip to content

Commit

Permalink
Make nix run able login shell register (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Sep 8, 2023
1 parent a57983e commit 8140655
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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";
Expand Down

0 comments on commit 8140655

Please sign in to comment.