attempt to make this work on nixos@Felia

nix-components
pegasust 2022-11-14 20:56:23 +00:00
parent c42d7f45c5
commit 142152e7c0
5 changed files with 116 additions and 88 deletions

View File

@ -31,78 +31,82 @@
pkgs = import nixpkgs { inherit system overlays; }; pkgs = import nixpkgs { inherit system overlays; };
lib = (import ../lib-nix { inherit pkgs from-yaml; lib = pkgs.lib; }); lib = (import ../lib-nix { inherit pkgs from-yaml; lib = pkgs.lib; });
in in
rec { {
homeConfigurations.nyx = home-manager.lib.homeManagerConfiguration { homeConfigurations =
inherit pkgs; let x11_wsl = ''
modules = [ # x11 output for WSL
./home.nix export DISPLAY=$(ip route list default | awk '{print $3}'):0
]; export LIBGL_ALWAYS_INDIRECT=1
# optionally pass inarguments to module '';
# we migrate this from in-place modules to allow flexibility in
# in this case, we can add "home" to input arglist of home.nix rec {
extraSpecialArgs = { "hungtr" = home-manager.lib.homeManagerConfiguration {
myLib = lib; inherit pkgs;
myHome = { modules = [
username = "nyx"; ./home.nix
homeDirectory = "/home/nyx"; ];
# 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";
};
};
}; };
}; "nixos@Felia" = home-manager.lib.homeManagerConfiguration {
}; inherit pkgs;
homeConfigurations.nixos = home-manager.lib.homeManagerConfiguration { modules = [
inherit pkgs; ./home.nix
modules = [ ];
./home.nix # optionally pass inarguments to module
]; # we migrate this from in-place modules to allow flexibility
# optionally pass inarguments to module # in this case, we can add "home" to input arglist of home.nix
# we migrate this from in-place modules to allow flexibility extraSpecialArgs = {
# in this case, we can add "home" to input arglist of home.nix myLib = lib;
extraSpecialArgs = { myHome = {
myLib = lib; username = "nixos";
myHome = { homeDirectory = "/home/nixos";
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
'';
}; };
}; "ubuntu_admin" = home-manager.lib.homeManagerConfiguration {
}; inherit pkgs;
homeConfigurations.ubuntu_admin = home-manager.lib.homeManagerConfiguration { modules = [
inherit pkgs; ./home.nix
modules = [ ];
./home.nix extraSpecialArgs = {
]; myLib = lib;
extraSpecialArgs = { myHome = {
myLib = lib; username = "ubuntu_admin";
myHome = { homeDirectory = "/home/ubuntu_admin";
username = "ubuntu_admin"; shellInitExtra = ''
homeDirectory = "/home/ubuntu_admin"; # x11 output for WSL
shellInitExtra = '' export DISPLAY=$(ip route list default | awk '{print $3}'):0
# x11 output for WSL export LIBGL_ALWAYS_INDIRECT=1
export DISPLAY=$(ip route list default | awk '{print $3}'):0 '';
export LIBGL_ALWAYS_INDIRECT=1 };
''; };
}; };
}; hwtr = home-manager.lib.homeManagerConfiguration {
}; inherit pkgs;
homeConfigurations.hwtr = home-manager.lib.homeManagerConfiguration { modules = [
inherit pkgs; ./home.nix
modules = [ ];
./home.nix extraSpecialArgs = {
]; myLib = lib;
extraSpecialArgs = { myHome = {
myLib = lib; username = "hwtr";
myHome = { homeDirectory = "/home/hwtr";
username = "hwtr"; packages = [ pkgs.nixgl.nixGLIntel ];
homeDirectory = "/home/hwtr"; shellAliases = {
packages = [ pkgs.nixgl.nixGLIntel ]; nixGL = "nixGLIntel";
shellAliases = { };
nixGL = "nixGLIntel"; };
}; };
}; };
}; };
};
}; };
} }

View File

@ -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; with lib;
{ {
imports = [ imports = [
/etc/nixos/hardware-configuration.nix ./profiles/${hostname}/hardware-configuration.nix
"${modulesPath}/profiles/minimal.nix" "${modulesPath}/profiles/minimal.nix"
]; ];
networking.hostName = hostname;
system.stateVersion = "22.05"; system.stateVersion = "22.05";
# users.users.<defaultUser>.uid = 1000; # users.users.<defaultUser>.uid = 1000;
@ -15,19 +19,19 @@ with lib;
nix.extraOptions = '' nix.extraOptions = ''
experimental-features = nix-command flakes experimental-features = nix-command flakes
''; '';
users.users.hungtr = { # users.users.hungtr = {
isNormalUser = true; # isNormalUser = true;
home = "/home/hungtr"; # home = "/home/hungtr";
description = "pegasust/hungtr"; # description = "pegasust/hungtr";
extraGroups = [ "wheel" "networkmanager" ]; # extraGroups = [ "wheel" "networkmanager" ];
openssh.authorizedKeys.keys = lib.strings.splitString "\n" (builtins.readFile ../ssh/authorized_keys); # 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 # Let's just open ssh server in general, even though it may not be
# network-accessible # network-accessible
services.openssh = { services.openssh = {
permitRootLogin = "no"; permitRootLogin = "no";
enable = true; enable = enableSSH;
}; };
# Some basic programs # Some basic programs

View File

@ -6,17 +6,44 @@
}; };
outputs = { self, nixpkgs, ... }: { outputs = { self, nixpkgs, ... }: {
# Windows with NixOS WSL
nixosConfigurations.Felia = nixpkgs.lib.nixosSystem { 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"; system = "x86_64-linux";
modules = [ modules = [
./configuration.nix ./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 { nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
./configuration.nix ./configuration.nix
]; ];
specialArgs = {
hostname = "nixos";
};
}; };
}; };
} }

View File

@ -17,12 +17,6 @@
fsType = "ext4"; fsType = "ext4";
}; };
fileSystems."/mnt/wsl" =
{
device = "tmpfs";
fsType = "tmpfs";
};
fileSystems."/mnt/wsl/docker-desktop/shared-sockets/guest-services" = fileSystems."/mnt/wsl/docker-desktop/shared-sockets/guest-services" =
{ {
device = "none"; device = "none";

View File

@ -1,4 +1,4 @@
{ lib, pkgs, config, modulesPath, ... }: { lib, ... }:
with lib; with lib;
let let
@ -6,9 +6,8 @@ let
in in
{ {
imports = [ imports = [
/etc/nixos/hardware-configuration.nix
nixos-wsl.nixosModules.wsl
./configuration.nix ./configuration.nix
nixos-wsl.nixosModules.wsl
]; ];
wsl = { wsl = {
@ -16,7 +15,7 @@ in
automountPath = "/mnt"; automountPath = "/mnt";
defaultUser = "nixos"; # if change defaultUser, make sure uid to be 1000 (first user) defaultUser = "nixos"; # if change defaultUser, make sure uid to be 1000 (first user)
startMenuLaunchers = true; startMenuLaunchers = true;
automountOptions = "drvfs,metadata,uid=1000,gid=100"; # automountOptions = "drvfs,metadata,uid=1000,gid=100";
# Enable native Docker support # Enable native Docker support
# docker-native.enable = true; # docker-native.enable = true;