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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,4 @@
{pkgs, ...}: {
imports = [
./shared
];
nixpkgs.config.allowUnfree = true;
nix = {
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";
in {
imports = [
./hardware.nix
../common/linux
];
{
config,
pkgs,
...
}: {
imports = [./hardware.nix];
networking = {
hostName = "futomaki";
@ -19,19 +18,14 @@ in {
blueman.enable = true;
openssh.enable = true;
pcscd.enable = true;
transmission.enable = true;
transmission.openFirewall = true;
};
virtualisation.docker.enable = true;
virtualisation.libvirtd.enable = true;
users.users."${mainUser}" = {
extraGroups = ["docker" "libvirtd" "wheel" "transmission"];
isNormalUser = true;
openssh.authorizedKeys.keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILm0O46zW/XfVOSwz0okRWYeOAg+wCVkCtCAoVTpZsOh"];
shell = pkgs.zsh;
};
system.stateVersion = "22.11";
users.users."${config.dotfiles.username}".extraGroups = ["docker" "libvirtd" "transmission"];
environment.systemPackages = with pkgs; [
(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 = {
host,
system,
@ -61,17 +57,36 @@
else if isDarwin
then "darwinModules"
else throw "Unsupported system";
hostPlatform =
if isLinux
then "linux"
else if isDarwin
then "darwin"
else throw "Unsupported system";
pkgs = inputs.nixpkgs.legacyPackages.${system};
inherit (pkgs.stdenv) isDarwin isLinux;
in {
${target}."${host}" = builder {
inherit system;
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]
++ [(hmCommonConfig {inherit username;})]
++ extraModules;
};
};
mkSystems = systems: mkMerge (map mkSystem systems);
mkSystems = systems: inputs.nixpkgs.lib.mkMerge (map mkSystem systems);
}

View file

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