!apXxbtexmNGJaAryzM:nixos.org

NixOS on WSL

347 Members
https://github.com/nix-community/NixOS-WSL61 Servers

Load older messages


SenderMessageTime
5 Mar 2023
@ajhalili2006:envs.net~ajhalili2006 [ ctrl-c.club / sr.ht / vern.cc ] joined the room.01:37:17
6 Mar 2023
@sandro:supersandro.deSandro 🐧Something about the sudo wrapper changed and it is broken for me.13:21:13
@sandro:supersandro.deSandro 🐧

I suspect that the permissions are wrong:

 ▶ ls -lah /run/wrappers/bin/sudo
.r-s--x--- root wheel 17 KB Mon Mar  6 14:19:11 2023  /run/wrappers/bin/sudo
13:21:33
@sandro:supersandro.deSandro 🐧

groups are fine

 ▶ id
uid=1000(sandro) gid=100(users) groups=100(users),1(wheel)
13:22:04
@sandro:supersandro.deSandro 🐧🤦13:22:25
@sandro:supersandro.deSandro 🐧I was testing PATH ordering last week and that messes it up13:23:23
@e-nikolov:matrix.orgEmil Nikolov joined the room.15:40:39
7 Mar 2023
@rdmolony:matrix.orgRowan Molony joined the room.17:25:23
@i97henka:matrix.orghenrik-ch

I am trying to get gpg working for my user on nixos wsl.

I have the following in my configuration.nix:

{ pkgs, config, modulesPath, ... }:

let
  #nixvim = import (builtins.fetchGit {
  #  url = "https://github.com/pta2002/nixvim";
  #});
  nixos-wsl = import ./nixos-wsl;
in
{
  imports = [
    #nixvim.nixosModules.nixvim
    nixos-wsl.nixosModules.wsl
    <home-manager/nixos>
  ];

  wsl = {
    enable = true;
    nativeSystemd = true;
    wslConf.automount.root = "/mnt";
    defaultUser = "nixos";
    startMenuLaunchers = true;

    # Enable native Docker support
    # docker-native.enable = true;

    # Enable integration with Docker Desktop (needs to be installed)
    # docker-desktop.enable = true;

  };

  # Enable nix flakes
  nix.package = pkgs.nixFlakes;
  nix.extraOptions = ''
    experimental-features = nix-command flakes
  '';

  #programs.nixvim.enable = true;

  users.users.i97henka = {
    isNormalUser = true;
    extraGroups = [ "wheel"];
  };

  home-manager.users.i97henka = { pkgs, ... }: {
    home.stateVersion = "22.11";
    home.packages = [ pkgs.jq pkgs.ripgrep pkgs.gh ];

    programs.bash = {
      enable = true;
      shellAliases = {
        ll = "ls -l";
        ".." = "cd ..";
        gst = "git status";
        glo = "git log --oneline";
        gfa = "git fetch --all";
        ggfl = "git push --force-with-lease";
      };
    };

    programs.git.enable = true;
    programs.direnv.enable = true;
    programs.direnv.nix-direnv.enable = true;
    programs.fzf.enable = true;
    programs.bat.enable = true;

    programs.gpg.enable = true;

    programs.neovim = {
      enable = true;
      defaultEditor = true;
      viAlias = true;
      vimAlias = true;
      vimdiffAlias = true;
    };
  };


  environment.systemPackages = with pkgs; [
    bat
    git
    vim
  ];

  system.stateVersion = "22.11";
}

I have added programs.gpg.enable = true;
but it didn't improve things.

I have seen this discourse thread:
https://discourse.nixos.org/t/cant-get-gnupg-to-work-no-pinentry/15373

but I am not sure how to apply it to my configuration.nix - I only added gpg in the home manager part - but maybe it should
be in a different part?

17:38:01
@k900:0upti.meK900What exactly is not working?17:39:10
@i97henka:matrix.orghenrik-ch

Thank you for chatting back K900 .
This is the command and the error:
gpg --symmetric --cipher-algo AES256 file_with_secrets.env

gpg: problem with the agent: No pinentry
gpg: error creating passphrase: Operation cancelled
gpg: symmetric encryption of 'file_with_secrets.env' failed: Operation cancelled
17:40:38
@k900:0upti.meK900Maybe use the NixOS setting instead of the home-manager one?17:41:42
@k900:0upti.meK900Looks like that got fixed to wokr by default17:41:47
@i97henka:matrix.orghenrik-ch

I change my configuration.nix, and I had problems previously to write a correct one, but now I got it through the sudo nixos-rebuild switch.

{ pkgs, config, modulesPath, ... }:

let
  #nixvim = import (builtins.fetchGit {
  #  url = "https://github.com/pta2002/nixvim";
  #});
  nixos-wsl = import ./nixos-wsl;
in
{
  imports = [
    #nixvim.nixosModules.nixvim
    nixos-wsl.nixosModules.wsl
    <home-manager/nixos>
  ];

  wsl = {
    enable = true;
    nativeSystemd = true;
    wslConf.automount.root = "/mnt";
    defaultUser = "nixos";
    startMenuLaunchers = true;

    # Enable native Docker support
    # docker-native.enable = true;

    # Enable integration with Docker Desktop (needs to be installed)
    # docker-desktop.enable = true;

  };

  # Enable nix flakes
  nix.package = pkgs.nixFlakes;
  nix.extraOptions = ''
    experimental-features = nix-command flakes
  '';


  #programs.nixvim.enable = true;

  users.users.i97henka = {
    isNormalUser = true;
    extraGroups = [ "wheel"];
  };

  home-manager.users.i97henka = { pkgs, ... }: {
    home.stateVersion = "22.11";
    home.packages = [ pkgs.jq pkgs.ripgrep pkgs.gh ];

    programs.bash = {
      enable = true;
      shellAliases = {
        ll = "ls -l";
        ".." = "cd ..";
        gst = "git status";
        glo = "git log --oneline";
        gfa = "git fetch --all";
        ggfl = "git push --force-with-lease";
      };
    };



    programs.git.enable = true;
    programs.direnv.enable = true;
    programs.direnv.nix-direnv.enable = true;
    programs.fzf.enable = true;
    programs.bat.enable = true;

    #programs.gpg.enable = true;


    programs.neovim = {
      enable = true;
      defaultEditor = true;
      viAlias = true;
      vimAlias = true;
      vimdiffAlias = true;
    #  plugins = with pkgs.vimPlugins; [
        #nvim-lspconfig
        #nvim-treesitter.withAllGrammars
        #plenary-nvim
        #gruvbox-material
        #mini-nvim
    #  ];
    };
  };


  environment.systemPackages = with pkgs; [
    bat
    git
    vim
  ];

  programs.gnupg.agent = {
    enable = true;
    enableSSHSupport = true;
    pinentryFlavor = "curses";
  };

  system.stateVersion = "22.11";
}

Sorry about the long config file chat.
That worked on my nixos user - now I can generate the env.gpg file.

17:51:10
@i97henka:matrix.orghenrik-ch Thanks a lot for guidance K900 . 17:51:22
@i97henka:matrix.orghenrik-chThere is one thing that still catches me out with that configuration.nix. It's working for the nixos user, but not for the i97henka user that I manage with home-manager. Is there an easy fix for that you think?18:45:00
@k900:0upti.meK900Why do you have two users? 18:46:05
@k900:0upti.meK900Just have one user18:46:18
@k900:0upti.meK900 The nixos user is in no way special and doesn't need to exist 18:46:32
@k900:0upti.meK900If you don't want it to 18:46:41
@i97henka:matrix.orghenrik-chMakes sense.18:46:52
@i97henka:matrix.orghenrik-chI changed the default user i my configuration.nix to i97henka. I did a nixos-rebuild switch and a wsl --shutdown and relaunched my terminal.18:50:43
@i97henka:matrix.orghenrik-chUnfortunately the gpg is still not working for the i97henka user. Maybe I am missing something here.18:51:10
@k900:0upti.meK900How exactly does it "not work" +18:51:42
@k900:0upti.meK900* How exactly does it "not work"? 18:51:46
@i97henka:matrix.orghenrik-ch

good point - same one let me share:

gpg --symmetric --cipher-algo AES256 file_with_secrets.env

gpg: problem with the agent: No pinentry
gpg: error creating passphrase: Operation cancelled
gpg: symmetric encryption of 'file_with_secrets.env' failed: Operation cancelled
18:52:50
@k900:0upti.meK900 Are you maybe starting another instance of gpg-agent in your shell config or something? 18:54:17
@i97henka:matrix.orghenrik-chthat may be the case18:54:37
@i97henka:matrix.orghenrik-ch
[i97henka@nixos:~/github]$ which gpg
/run/current-system/sw/bin/gpg

That looks a bit unusual to me, but I haven't got much unix experience 😄

18:55:45
@k900:0upti.meK900That is normal for NixOS 18:55:56

Show newer messages


Back to Room ListRoom Version: 9