Skip to content

configure using NixOS module#4

Merged
Mic92 merged 19 commits intoMic92:masterfrom
dermetfan:nixos-config
Jan 30, 2019
Merged

configure using NixOS module#4
Mic92 merged 19 commits intoMic92:masterfrom
dermetfan:nixos-config

Conversation

@dermetfan
Copy link
Copy Markdown
Contributor

@dermetfan dermetfan commented Jan 29, 2019

This is my response to #3.

Additionally in a29fe70 I enabled the module of the user's shell, e.g. programs.zsh and in d15bdea allowed SSH login with the user's key. If desired I can split those out into different PRs.


environment = {
systemPackages = with pkgs; [
xterm # for resize command
Copy link
Copy Markdown
Owner

@Mic92 Mic92 Jan 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in this pr, but this would shell script would be probably more lightweight:

https://github.com/nix-community/nixos-generators/blob/master/formats/vm-nogui.nix#L3

Comment thread share/nixos-shell/nixos-shell.nix Outdated

# Allow passwordless ssh login with the user's key if it exists.
(let
pubkey = "${builtins.getEnv "HOME"}/.ssh/id_rsa.pub";
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you mention this in the readme?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would at least also check for id_ecdsa.pub and id_ed25519.pub.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(let
  keys = lib.map (key: "${builtins.getEnv "HOME"}/.ssh/${key}")
    ["id_rsa.pub" "id_ecdsa.pub" "id_ed25519.pub"];
in {
  users.users.root.openssh.authorizedKeys.keyFiles = lib.filter builtins.pathExists keys;
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wishlist: Would it be possible to add the output of ssh-add -L? That would take care of all keys an ssh agent has, for example the keys stored on a yubikey.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the snippet, applied.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tokudan that might be possible by using an environment variable that is set in nixos-shell.

@Mic92 Mic92 merged commit dddfdd9 into Mic92:master Jan 30, 2019
@Mic92
Copy link
Copy Markdown
Owner

Mic92 commented Jan 30, 2019

Thanks! No it looks solid.

@Mic92
Copy link
Copy Markdown
Owner

Mic92 commented Jan 30, 2019

Only forwardings are not declarative yet:

QEMU_NET_OPTS="hostfwd=tcp::2222-:22"

Comment thread bin/nixos-shell

script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export QEMU_KERNEL_PARAMS="console=ttyS0 ${QEMU_KERNEL_PARAMS:-}"
export QEMU_PATH=${PATH:-}
Copy link
Copy Markdown
Owner

@Mic92 Mic92 Jan 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here was to capture $PATH of the user in case there were some project-specific PATH entries like script directories added.
Or the user has something like ~/bin/, also this is probably
restored by re-evaluating ~/.bashrc or ~/.zshrc.
I don't think we would need this in a declarative form, do you?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, in that case couldn't we just builtins.getEnv "PATH"? I was wondering why you introduced a new env variable.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants