From 142152e7c06994c4b087e506f25b256b25a1c057 Mon Sep 17 00:00:00 2001 From: pegasust Date: Mon, 14 Nov 2022 20:56:23 +0000 Subject: [PATCH] attempt to make this work on nixos@Felia --- home-nix/flake.nix | 138 +++++++++--------- system-nix/configuration.nix | 24 +-- system-nix/flake.nix | 29 +++- .../profiles/Felia/hardware-configuration.nix | 6 - system-nix/wsl-configuration.nix | 7 +- 5 files changed, 116 insertions(+), 88 deletions(-) diff --git a/home-nix/flake.nix b/home-nix/flake.nix index 1cb0a15..51c3fac 100644 --- a/home-nix/flake.nix +++ b/home-nix/flake.nix @@ -31,78 +31,82 @@ pkgs = import nixpkgs { inherit system overlays; }; lib = (import ../lib-nix { inherit pkgs from-yaml; lib = pkgs.lib; }); in - rec { - homeConfigurations.nyx = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = [ - ./home.nix - ]; - # optionally pass inarguments to module - # we migrate this from in-place modules to allow flexibility - # in this case, we can add "home" to input arglist of home.nix - extraSpecialArgs = { - myLib = lib; - myHome = { - username = "nyx"; - homeDirectory = "/home/nyx"; + { + homeConfigurations = + let x11_wsl = '' + # x11 output for WSL + export DISPLAY=$(ip route list default | awk '{print $3}'):0 + export LIBGL_ALWAYS_INDIRECT=1 + ''; + in + rec { + "hungtr" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ + ./home.nix + ]; + # optionally pass inarguments to module + # we migrate this from in-place modules to allow flexibility + # in this case, we can add "home" to input arglist of home.nix + extraSpecialArgs = { + myLib = lib; + myHome = { + username = "hungtr"; + homeDirectory = "/home/hungtr"; + }; + }; }; - }; - }; - homeConfigurations.nixos = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = [ - ./home.nix - ]; - # optionally pass inarguments to module - # we migrate this from in-place modules to allow flexibility - # in this case, we can add "home" to input arglist of home.nix - extraSpecialArgs = { - myLib = lib; - myHome = { - username = "nixos"; - homeDirectory = "/home/nixos"; - shellInitExtra = '' - # x11 output for WSL - export DISPLAY=$(ip route list default | awk '{print $3}'):0 - export LIBGL_ALWAYS_INDIRECT=1 - ''; + "nixos@Felia" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ + ./home.nix + ]; + # optionally pass inarguments to module + # we migrate this from in-place modules to allow flexibility + # in this case, we can add "home" to input arglist of home.nix + extraSpecialArgs = { + myLib = lib; + myHome = { + username = "nixos"; + homeDirectory = "/home/nixos"; + }; + }; }; - }; - }; - homeConfigurations.ubuntu_admin = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = [ - ./home.nix - ]; - extraSpecialArgs = { - myLib = lib; - myHome = { - username = "ubuntu_admin"; - homeDirectory = "/home/ubuntu_admin"; - shellInitExtra = '' - # x11 output for WSL - export DISPLAY=$(ip route list default | awk '{print $3}'):0 - export LIBGL_ALWAYS_INDIRECT=1 - ''; + "ubuntu_admin" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ + ./home.nix + ]; + extraSpecialArgs = { + myLib = lib; + myHome = { + username = "ubuntu_admin"; + homeDirectory = "/home/ubuntu_admin"; + shellInitExtra = '' + # x11 output for WSL + export DISPLAY=$(ip route list default | awk '{print $3}'):0 + export LIBGL_ALWAYS_INDIRECT=1 + ''; + }; + }; }; - }; - }; - homeConfigurations.hwtr = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = [ - ./home.nix - ]; - extraSpecialArgs = { - myLib = lib; - myHome = { - username = "hwtr"; - homeDirectory = "/home/hwtr"; - packages = [ pkgs.nixgl.nixGLIntel ]; - shellAliases = { - nixGL = "nixGLIntel"; + hwtr = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ + ./home.nix + ]; + extraSpecialArgs = { + myLib = lib; + myHome = { + username = "hwtr"; + homeDirectory = "/home/hwtr"; + packages = [ pkgs.nixgl.nixGLIntel ]; + shellAliases = { + nixGL = "nixGLIntel"; + }; + }; }; }; }; - }; }; } diff --git a/system-nix/configuration.nix b/system-nix/configuration.nix index 95f40b5..bb16293 100755 --- a/system-nix/configuration.nix +++ b/system-nix/configuration.nix @@ -1,10 +1,14 @@ -{ lib, pkgs, config, modulesPath, ... }: +{ lib, pkgs, config, modulesPath, specialArgs, ... }: +let hostname = specialArgs.hostname; + enableSSH = specialArgs.enableSSH or true; +in with lib; { imports = [ - /etc/nixos/hardware-configuration.nix + ./profiles/${hostname}/hardware-configuration.nix "${modulesPath}/profiles/minimal.nix" ]; + networking.hostName = hostname; system.stateVersion = "22.05"; # users.users..uid = 1000; @@ -15,19 +19,19 @@ with lib; nix.extraOptions = '' experimental-features = nix-command flakes ''; - users.users.hungtr = { - isNormalUser = true; - home = "/home/hungtr"; - description = "pegasust/hungtr"; - extraGroups = [ "wheel" "networkmanager" ]; - openssh.authorizedKeys.keys = lib.strings.splitString "\n" (builtins.readFile ../ssh/authorized_keys); - }; + # users.users.hungtr = { + # isNormalUser = true; + # home = "/home/hungtr"; + # description = "pegasust/hungtr"; + # extraGroups = [ "wheel" "networkmanager" ]; + # openssh.authorizedKeys.keys = lib.strings.splitString "\n" (builtins.readFile ../ssh/authorized_keys); + # }; # Let's just open ssh server in general, even though it may not be # network-accessible services.openssh = { permitRootLogin = "no"; - enable = true; + enable = enableSSH; }; # Some basic programs diff --git a/system-nix/flake.nix b/system-nix/flake.nix index c0303ec..7e7d2f0 100644 --- a/system-nix/flake.nix +++ b/system-nix/flake.nix @@ -4,19 +4,46 @@ home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; }; - + outputs = { self, nixpkgs, ... }: { + # Windows with NixOS WSL nixosConfigurations.Felia = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./wsl-configuration.nix + ]; + specialArgs = { + hostname = "Felia"; + enableSSH = false; + }; + }; + # Generic machine + nixosConfigurations.lizzi = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ ./configuration.nix ]; + specialArgs = { + hostname = "lizzi"; + }; + }; + nixosConfigurations.nyx = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./configuration.nix + ]; + specialArgs = { + hostname = "nyx"; + }; }; nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ ./configuration.nix ]; + specialArgs = { + hostname = "nixos"; + }; }; }; } diff --git a/system-nix/profiles/Felia/hardware-configuration.nix b/system-nix/profiles/Felia/hardware-configuration.nix index 589d639..2e25765 100644 --- a/system-nix/profiles/Felia/hardware-configuration.nix +++ b/system-nix/profiles/Felia/hardware-configuration.nix @@ -17,12 +17,6 @@ fsType = "ext4"; }; - fileSystems."/mnt/wsl" = - { - device = "tmpfs"; - fsType = "tmpfs"; - }; - fileSystems."/mnt/wsl/docker-desktop/shared-sockets/guest-services" = { device = "none"; diff --git a/system-nix/wsl-configuration.nix b/system-nix/wsl-configuration.nix index 7663a13..48fd9d3 100755 --- a/system-nix/wsl-configuration.nix +++ b/system-nix/wsl-configuration.nix @@ -1,4 +1,4 @@ -{ lib, pkgs, config, modulesPath, ... }: +{ lib, ... }: with lib; let @@ -6,9 +6,8 @@ let in { imports = [ - /etc/nixos/hardware-configuration.nix - nixos-wsl.nixosModules.wsl ./configuration.nix + nixos-wsl.nixosModules.wsl ]; wsl = { @@ -16,7 +15,7 @@ in automountPath = "/mnt"; defaultUser = "nixos"; # if change defaultUser, make sure uid to be 1000 (first user) startMenuLaunchers = true; - automountOptions = "drvfs,metadata,uid=1000,gid=100"; + # automountOptions = "drvfs,metadata,uid=1000,gid=100"; # Enable native Docker support # docker-native.enable = true;