feat: rework shared/common lib

This commit is contained in:
winston 2023-06-24 21:24:20 +02:00
parent 10ea13464f
commit cf94e26b80
Signed by: winston
GPG key ID: 3786770EDBC2B481
9 changed files with 70 additions and 50 deletions

View file

@ -1,10 +1,9 @@
{pkgs, ...}: let {
mainUser = "w"; config,
in { pkgs,
imports = [ ...
./hardware.nix }: {
../common/linux imports = [./hardware.nix];
];
boot = { boot = {
kernelPackages = pkgs.linuxPackages_latest; kernelPackages = pkgs.linuxPackages_latest;
@ -31,13 +30,5 @@ in {
}; };
virtualisation.docker.enable = true; virtualisation.docker.enable = true;
users.users."${config.dotfiles.username}".extraGroups = ["docker"];
users.users."${mainUser}" = {
extraGroups = ["wheel" "docker"];
isNormalUser = true;
openssh.authorizedKeys.keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILm0O46zW/XfVOSwz0okRWYeOAg+wCVkCtCAoVTpZsOh"];
shell = pkgs.zsh;
};
system.stateVersion = "22.11";
} }

View file

@ -2,8 +2,6 @@
# manipulate the global /etc/zshenv for PATH, etc. # manipulate the global /etc/zshenv for PATH, etc.
programs.zsh.enable = true; programs.zsh.enable = true;
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 4; system.stateVersion = 4;
security.pam.enableSudoTouchIdAuth = true; security.pam.enableSudoTouchIdAuth = true;

View file

@ -36,4 +36,6 @@
programs.nix-ld.enable = true; programs.nix-ld.enable = true;
programs.zsh.enable = true; programs.zsh.enable = true;
system.stateVersion = "22.11";
} }

View file

@ -1,5 +1,7 @@
{ {
imports = [ imports = [
./nix.nix
./podman.nix ./podman.nix
./user.nix
]; ];
} }

View file

@ -1,7 +1,4 @@
{pkgs, ...}: { {pkgs, ...}: {
imports = [
./shared
];
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
nix = { nix = {
gc.automatic = true; gc.automatic = true;

View file

@ -0,0 +1,28 @@
{
config,
lib,
pkgs,
...
}: let
homeRoot =
if pkgs.stdenv.isDarwin
then "/Users"
else if pkgs.stdenv.isLinux
then "/home"
else throw "Unsupported OS";
in {
users.users."${config.dotfiles.username}" =
{
home = "${homeRoot}/${config.dotfiles.username}";
openssh.authorizedKeys.keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILm0O46zW/XfVOSwz0okRWYeOAg+wCVkCtCAoVTpZsOh"];
shell = pkgs.zsh;
}
// (
if pkgs.stdenv.isLinux
then {
isNormalUser = lib.mkIf pkgs.stdenv.isLinux true;
extraGroups = ["wheel"];
}
else {}
);
}

View file

@ -1,10 +1,9 @@
{pkgs, ...}: let {
mainUser = "winston"; config,
in { pkgs,
imports = [ ...
./hardware.nix }: {
../common/linux imports = [./hardware.nix];
];
networking = { networking = {
hostName = "futomaki"; hostName = "futomaki";
@ -19,19 +18,14 @@ in {
blueman.enable = true; blueman.enable = true;
openssh.enable = true; openssh.enable = true;
pcscd.enable = true; pcscd.enable = true;
transmission.enable = true;
transmission.openFirewall = true;
}; };
virtualisation.docker.enable = true; virtualisation.docker.enable = true;
virtualisation.libvirtd.enable = true; virtualisation.libvirtd.enable = true;
users.users."${mainUser}" = { users.users."${config.dotfiles.username}".extraGroups = ["docker" "libvirtd" "transmission"];
extraGroups = ["docker" "libvirtd" "wheel" "transmission"];
isNormalUser = true;
openssh.authorizedKeys.keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILm0O46zW/XfVOSwz0okRWYeOAg+wCVkCtCAoVTpZsOh"];
shell = pkgs.zsh;
};
system.stateVersion = "22.11";
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
(discord.override {withOpenASAR = true;}) (discord.override {withOpenASAR = true;})
@ -54,7 +48,4 @@ in {
}; };
}; };
}; };
services.transmission.enable = true;
services.transmission.openFirewall = true;
} }

View file

@ -33,10 +33,6 @@
}; };
}; };
}); });
mkMerge = contents: {
_type = "merge";
inherit contents;
};
mkSystem = { mkSystem = {
host, host,
system, system,
@ -61,17 +57,36 @@
else if isDarwin else if isDarwin
then "darwinModules" then "darwinModules"
else throw "Unsupported system"; else throw "Unsupported system";
hostPlatform =
if isLinux
then "linux"
else if isDarwin
then "darwin"
else throw "Unsupported system";
pkgs = inputs.nixpkgs.legacyPackages.${system}; pkgs = inputs.nixpkgs.legacyPackages.${system};
inherit (pkgs.stdenv) isDarwin isLinux; inherit (pkgs.stdenv) isDarwin isLinux;
in { in {
${target}."${host}" = builder { ${target}."${host}" = builder {
inherit system; inherit system;
modules = with inputs; modules = with inputs;
[./common ./${host} home-manager.${module}.home-manager] [
{
options.dotfiles.username = with pkgs.lib;
mkOption {
description = "Main user of this configuration.";
type = types.str;
default = "${username}";
};
}
./common/shared
./common/${hostPlatform}
./${host}
home-manager.${module}.home-manager
]
++ pkgs.lib.optionals isDarwin [nekowinston-nur.darwinModules.default] ++ pkgs.lib.optionals isDarwin [nekowinston-nur.darwinModules.default]
++ [(hmCommonConfig {inherit username;})] ++ [(hmCommonConfig {inherit username;})]
++ extraModules; ++ extraModules;
}; };
}; };
mkSystems = systems: mkMerge (map mkSystem systems); mkSystems = systems: inputs.nixpkgs.lib.mkMerge (map mkSystem systems);
} }

View file

@ -1,10 +1,6 @@
{ {
imports = [ imports = [./brew.nix];
./brew.nix
../common/darwin
];
users.users.winston.home = "/Users/winston";
networking.computerName = "sashimi"; networking.computerName = "sashimi";
networking.hostName = "sashimi"; networking.hostName = "sashimi";
} }