refac: use home as nixos module

This commit is contained in:
Dmitriy Pleshevskiy 2022-10-08 22:45:35 +03:00
parent 3170700efe
commit b9835b5c6f
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
14 changed files with 107 additions and 113 deletions

View file

@ -38,18 +38,29 @@
}; };
}; };
outputs = inputs @ { self, nixpkgs, ... }: outputs = inputs @ { self, nixpkgs, hardware, ... }:
let let
system = "x86_64-linux"; system = "x86_64-linux";
in in
{ {
homeConfigurations = import ./outputs/home.nix { nixosConfigurations =
inherit inputs system; nixpkgs.lib.mapAttrs
}; (hostname: { system
, specialArgs ? { }
, extraModules ? [ ]
, nixpkgs ? inputs.nixpkgs
}:
nixpkgs.lib.nixosSystem {
inherit system;
nixosConfigurations = import ./outputs/system.nix { specialArgs = { inherit inputs; } // specialArgs;
inherit inputs system;
}; modules =
(with inputs; [ home-manager.nixosModule ])
++ [ ./machines/${hostname} ]
++ extraModules;
})
(import ./machines inputs);
devShells.${system} = devShells.${system} =
let let

View file

@ -1,24 +1,24 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
secrets = import ../../../secrets.nix; secrets = import ../../secrets.nix;
in in
{ {
imports = [ imports = [
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
../common.nix
]; ];
# Use latest kernel
boot.kernelPackages = pkgs.linuxPackages_latest;
# Use the systemd-boot EFI boot loader. # Use the systemd-boot EFI boot loader.
boot = { boot.loader = {
loader = {
systemd-boot.enable = true; systemd-boot.enable = true;
efi.canTouchEfiVariables = true; efi.canTouchEfiVariables = true;
}; };
kernelPackages = pkgs.linuxPackages_latest;
};
networking = { networking = {
hostName = "laptop"; # Define your hostname. hostName = "laptop"; # Define your hostname.
inherit (secrets.networking) extraHosts; inherit (secrets.networking) extraHosts;
@ -33,7 +33,7 @@ in
hardware.bluetooth.enable = true; hardware.bluetooth.enable = true;
services.blueman.enable = true; services.blueman.enable = true;
# configure touchpad # configure mouse and touchpad
services.xserver.libinput = { services.xserver.libinput = {
enable = true; enable = true;
mouse = { mouse = {

View file

@ -4,9 +4,6 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
let
secrets = import ../secrets.nix;
in
{ {
networking = { networking = {
networkmanager.enable = true; networkmanager.enable = true;
@ -56,9 +53,6 @@ in
# Enable the X11 windowing system. # Enable the X11 windowing system.
services = { services = {
# Enable the OpenSSH daemon.
openssh.enable = true;
# Xmonad # Xmonad
dbus = { dbus = {
enable = true; enable = true;
@ -95,17 +89,6 @@ in
programs.zsh.enable = true; programs.zsh.enable = true;
# Define a user account. Don't forget to set a password with passwd. # Define a user account. Don't forget to set a password with passwd.
users.users.me = {
isNormalUser = true;
name = secrets.mainUser.userName;
home = secrets.mainUser.userDir;
extraGroups = [
"wheel" # Enable sudo for the user.
"networkmanager"
"docker"
];
shell = pkgs.zsh;
};
# List packages installed in system profile. To search, run: # List packages installed in system profile. To search, run:
# $ nix search wget # $ nix search wget
@ -115,6 +98,9 @@ in
wget wget
]; ];
# Enable the OpenSSH daemon.
services.openssh.enable = true;
# Some programs need SUID wrappers, can be configured further or are # Some programs need SUID wrappers, can be configured further or are
# started in user sessions. # started in user sessions.
# programs.mtr.enable = true; # programs.mtr.enable = true;
@ -131,7 +117,7 @@ in
settings = { settings = {
auto-optimise-store = true; auto-optimise-store = true;
trusted-users = [ "root" secrets.mainUser.userName ]; trusted-users = [ "root" ];
experimental-features = [ "nix-command" "flakes" ]; experimental-features = [ "nix-command" "flakes" ];

30
machines/default.nix Normal file
View file

@ -0,0 +1,30 @@
{ dedsec-grub-theme, ... } @ inputs:
let
hardware = inputs.hardware.nixosModules;
in
{
home = {
system = "x86_64-linux";
extraModules = [
dedsec-grub-theme.nixosModule
../modules/garbage-collector.nix
../users/jan
];
};
asus_gl553vd = {
system = "x86_64-linux";
specialArgs = {
fontSize = 6.0;
};
extraModules = [
hardware.common-cpu-intel
../users/jan
];
};
}

View file

@ -1,12 +1,13 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
secrets = import ../../../secrets.nix; secrets = import ../../secrets.nix;
in in
{ {
imports = [ imports = [
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
../common.nix
]; ];
boot = { boot = {

View file

@ -1,17 +1,10 @@
switchHm = home-manager switch --flake
switchSys = nixos-rebuild switch --flake switchSys = nixos-rebuild switch --flake
users-jan: fix-systemd
${switchHm} .#users-jan
users-laptop-jan: fix-systemd
${switchHm} .#users-laptop-jan
sys-home: sys-home:
sudo ${switchSys} .#system-home sudo ${switchSys} .#home
sys-asus-gl553vd: sys-asus-gl553vd:
sudo ${switchSys} .#system-asus-gl553vd sudo ${switchSys} .#asus_gl553vd
fix-systemd: fix-systemd:
systemctl --user reset-failed systemctl --user reset-failed

View file

@ -1,33 +0,0 @@
{ inputs, system, ... }:
with inputs;
let
pkgs = import nixpkgs {
inherit system;
overlays = [
inputs.wired.overlays.default
inputs.myneovim.overlays.default
inputs.vnetod.overlay
inputs.nil.overlays.default
];
};
mkUsersJan = mods: home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
inputs.wired.homeManagerModules.default
../users/jan/home.nix
] ++ mods;
};
in
{
users-jan = mkUsersJan [ ];
users-laptop-jan = mkUsersJan [
({ config, ... }: {
progs.alacritty.fontSize = 6.0;
})
];
}

View file

@ -1,22 +0,0 @@
{ inputs, system, ... }:
with inputs;
{
system-home = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
dedsec-grub-theme.nixosModule
../system/configuration.nix
../system/garbage-collector.nix
../system/machine/home
];
};
system-asus-gl553vd = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
hardware.nixosModules.common-cpu-intel
../system/configuration.nix
../system/machine/asus_gl553vd
];
};
}

Binary file not shown.

42
users/jan/default.nix Normal file
View file

@ -0,0 +1,42 @@
{ config, pkgs, lib, inputs, fontSize ? null, ... }:
let
secrets = import ./secrets.nix;
in
{
nixpkgs.overlays = (import ../../overlays) ++ [
inputs.wired.overlays.default
inputs.myneovim.overlays.default
inputs.vnetod.overlay
inputs.nil.overlays.default
];
users.users.jan = {
isNormalUser = true;
name = secrets.userName;
home = secrets.userDir;
extraGroups = [
"wheel" # Enable sudo for the user.
"networkmanager"
"docker"
];
shell = pkgs.zsh;
};
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.jan = { lib, ... }: {
imports = [
inputs.wired.homeManagerModules.default
./home.nix
];
progs.alacritty.fontSize = lib.mkIf (fontSize != null) fontSize;
home.stateVersion = config.system.stateVersion;
};
};
nix.settings.trusted-users = lib.mkForce [ "root" secrets.userName ];
}

View file

@ -6,8 +6,6 @@ in
{ {
imports = (import ./ui) ++ (import ./shell) ++ (import ./progs); imports = (import ./ui) ++ (import ./shell) ++ (import ./progs);
nixpkgs.overlays = import ../../overlays;
# Home Manager needs a bit of information about you and the # Home Manager needs a bit of information about you and the
# paths it should manage. # paths it should manage.
home.username = secrets.userName; home.username = secrets.userName;
@ -136,16 +134,4 @@ in
enable = true; enable = true;
config = ./wired.ron; config = ./wired.ron;
}; };
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
home.stateVersion = "21.11";
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
} }