move vars into a separate file

This commit is contained in:
Andreas Zweili 2022-02-21 11:36:12 +01:00
parent 075576d220
commit 85c73e44f0
19 changed files with 45 additions and 45 deletions

4
custom/default.nix Normal file
View File

@ -0,0 +1,4 @@
{
username = "andreas";
system = "x86_64-linux";
}

View File

@ -12,10 +12,6 @@
url = "github:nix-community/home-manager/release-21.11"; url = "github:nix-community/home-manager/release-21.11";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
custom = {
system = "x86_64-linux";
username = "andreas";
};
}; };
outputs = outputs =
@ -24,9 +20,9 @@
, nixpkgs-unstable , nixpkgs-unstable
, nixos-hardware , nixos-hardware
, home-manager , home-manager
, custom
}: }:
let let
custom = import ./custom;
system = custom.system; system = custom.system;
overlay-unstable = final: prev: { overlay-unstable = final: prev: {
unstable = import nixpkgs-unstable { unstable = import nixpkgs-unstable {
@ -46,7 +42,7 @@
}; };
mkComputer = configurationNix: homeManagerRole: extraModules: nixpkgs.lib.nixosSystem { mkComputer = configurationNix: homeManagerRole: extraModules: nixpkgs.lib.nixosSystem {
inherit system pkgs; inherit system pkgs;
specialArgs = { inherit inputs; }; specialArgs = { inherit custom inputs; };
modules = ( modules = (
[ [
# System configuration for this host # System configuration for this host
@ -60,7 +56,7 @@
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.users.${custom.username}.imports = [ home-manager.users.${custom.username}.imports = [
(import homeManagerRole { inherit pkgs inputs; }) (import homeManagerRole { inherit custom pkgs inputs; })
]; ];
} }
] ++ extraModules ] ++ extraModules

View File

@ -1,8 +1,8 @@
{ inputs, ... }: { inputs, custom, ... }:
{ {
# 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 = inputs.custom.username; home.username = custom.username;
home.homeDirectory = "/home/${inputs.custom.username}"; home.homeDirectory = "/home/${custom.username}";
programs.home-manager.enable = true; programs.home-manager.enable = true;
} }

View File

@ -1,7 +1,7 @@
{ inputs, pkgs, ... }: { inputs, custom, pkgs, ... }:
{ {
imports = [ imports = [
(import ./common { inherit inputs; }) (import ./common { inherit custom inputs; })
./software/work-desktop ./software/work-desktop
./software/autorandr ./software/autorandr
./software/calibre ./software/calibre

View File

@ -1,4 +1,4 @@
{ inputs, pkgs, ... }: { inputs, custom, pkgs, ... }:
{ {
imports = [ imports = [
(import ./common { inherit inputs; }) (import ./common { inherit inputs; })

View File

@ -1,4 +1,4 @@
{ inputs, pkgs, ... }: { inputs, custom, pkgs, ... }:
{ {
imports = [ imports = [
./common ./common
@ -14,7 +14,7 @@
enable = true; enable = true;
bashrcExtra = '' bashrcExtra = ''
. ~/.nixos/home-manager/configs/bash/work_wsl_bashrc . ~/.nixos/home-manager/configs/bash/work_wsl_bashrc
. /home/${inputs.custom.username}/.nix-profile/etc/profile.d/nix.sh . /home/${custom.username}/.nix-profile/etc/profile.d/nix.sh
''; '';
}; };
} }

View File

@ -1,8 +1,8 @@
{ inputs, pkgs, ... }: { inputs, custom, pkgs, ... }:
{ {
services.code-server = { services.code-server = {
enable = true; enable = true;
user = inputs.custom.username; user = custom.username;
host = "0.0.0.0"; host = "0.0.0.0";
auth = "none"; auth = "none";
extraPackages = with pkgs; extraPackages = with pkgs;
@ -14,7 +14,7 @@
git git
]; ];
extraEnvironment = { extraEnvironment = {
HOME = "/home/${inputs.custom.username}"; HOME = "/home/${custom.username}";
}; };
}; };
networking.firewall.allowedTCPPorts = [ 4444 ]; networking.firewall.allowedTCPPorts = [ 4444 ];

View File

@ -1,4 +1,4 @@
{ inputs, pkgs, ... }: { inputs, custom, pkgs, ... }:
{ {
imports = [ imports = [
"${inputs.self}/modules/cli" "${inputs.self}/modules/cli"
@ -49,7 +49,7 @@
# Disable the root user # Disable the root user
users.users.root.hashedPassword = "!"; users.users.root.hashedPassword = "!";
# 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.${inputs.custom.username} = { users.users.${custom.username} = {
isNormalUser = true; isNormalUser = true;
initialPassword = "password"; initialPassword = "password";
extraGroups = [ extraGroups = [

View File

@ -1,4 +1,4 @@
{ inputs, pkgs, ... }: { inputs, custom, pkgs, ... }:
{ {
networking = { networking = {
networkmanager.enable = true; networkmanager.enable = true;
@ -59,7 +59,7 @@
terminator terminator
]; ];
environment.shellAliases = { environment.shellAliases = {
management-server = "mosh ${inputs.custom.username}@10.7.89.150 tmux a"; management-server = "mosh ${custom.username}@10.7.89.150 tmux a";
}; };
} }

View File

@ -1,11 +1,11 @@
{ inputs, pkgs, ... }: { inputs, custom, pkgs, ... }:
{ {
virtualisation.docker = virtualisation.docker =
{ {
enable = true; enable = true;
autoPrune.enable = true; autoPrune.enable = true;
}; };
users.users.${inputs.custom.username}.extraGroups = [ "docker" ]; users.users.${custom.username}.extraGroups = [ "docker" ];
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
docker-compose docker-compose
lazydocker lazydocker

View File

@ -1,4 +1,4 @@
{ inputs, pkgs, ... }: { inputs, custom, pkgs, ... }:
{ {
programs.droidcam.enable = true; programs.droidcam.enable = true;
# required for USB connection # required for USB connection
@ -6,7 +6,7 @@
environment.shellAliases = { environment.shellAliases = {
webcam = "droidcam-cli -size=1920x1080 ios 4747"; webcam = "droidcam-cli -size=1920x1080 ios 4747";
}; };
home-manager.users.${inputs.custom.username} = { home-manager.users.${custom.username} = {
xdg.desktopEntries = { xdg.desktopEntries = {
droidcam = { droidcam = {
name = "Droidcam"; name = "Droidcam";

View File

@ -1,10 +1,10 @@
{ inputs, pkgs, ... }: { inputs, custom, pkgs, ... }:
{ {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
gnome.eog gnome.eog
]; ];
home-manager.users.${inputs.custom.username} = { home-manager.users.${custom.username} = {
xdg.mimeApps = { xdg.mimeApps = {
enable = true; enable = true;
associations.added = { associations.added = {

View File

@ -1,7 +1,7 @@
{ inputs, pkgs, ... }: { inputs, custom, pkgs, ... }:
{ {
services.espanso.enable = true; services.espanso.enable = true;
home-manager.users.${inputs.custom.username} = { home-manager.users.${custom.username} = {
xdg.configFile.espanso = { xdg.configFile.espanso = {
target = "espanso/default.yml"; target = "espanso/default.yml";
onChange = "systemctl --user restart espanso"; onChange = "systemctl --user restart espanso";

View File

@ -1,11 +1,11 @@
{ inputs, pkgs, ... }: { inputs, custom, pkgs, ... }:
{ {
nix.extraOptions = '' nix.extraOptions = ''
keep-outputs = true keep-outputs = true
keep-derivations = true keep-derivations = true
''; '';
home-manager.users.${inputs.custom.username} = { home-manager.users.${custom.username} = {
programs.direnv.enable = true; programs.direnv.enable = true;
programs.direnv.nix-direnv.enable = true; programs.direnv.nix-direnv.enable = true;
programs.direnv.nix-direnv.enableFlakes = true; programs.direnv.nix-direnv.enableFlakes = true;

View File

@ -1,11 +1,11 @@
{ inputs, time, ... }: { inputs, custom, time, ... }:
{ {
services.restic.backups.${inputs.custom.username} = { services.restic.backups.${custom.username} = {
user = "root"; user = "root";
repository = "rest:http://10.7.89.30:8000"; repository = "rest:http://10.7.89.30:8000";
timerConfig.OnCalendar = time; timerConfig.OnCalendar = time;
passwordFile = "/home/${inputs.custom.username}/.nixos/secrets/passwords/restic.key"; passwordFile = "/home/${custom.username}/.nixos/secrets/passwords/restic.key";
paths = [ "/home/${inputs.custom.username}/" ]; paths = [ "/home/${custom.username}/" ];
extraBackupArgs = [ extraBackupArgs = [
"--exclude-file=${inputs.self}/modules/restic/excludes.txt" "--exclude-file=${inputs.self}/modules/restic/excludes.txt"
]; ];

View File

@ -1,4 +1,4 @@
{ inputs, pkgs, ... }: { inputs, custom, pkgs, ... }:
let let
repository = "/mnt/restic-server"; repository = "/mnt/restic-server";
in in

View File

@ -1,18 +1,18 @@
{ inputs, pkgs, ... }: { inputs, custom, pkgs, ... }:
{ {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
restic restic
]; ];
services.restic.backups.${inputs.custom.username} = { services.restic.backups.${custom.username} = {
user = inputs.custom.username; user = custom.username;
repository = "rest:http://10.7.89.30:8000"; repository = "rest:http://10.7.89.30:8000";
timerConfig = { timerConfig = {
OnCalendar = "hourly"; OnCalendar = "hourly";
RandomizedDelaySec = "15min"; RandomizedDelaySec = "15min";
}; };
passwordFile = "/home/${inputs.custom.username}/.nixos/secrets/passwords/restic.key"; passwordFile = "/home/${custom.username}/.nixos/secrets/passwords/restic.key";
paths = [ "/home/${inputs.custom.username}/" ]; paths = [ "/home/${custom.username}/" ];
extraBackupArgs = [ extraBackupArgs = [
"--exclude-file=${inputs.self}/modules/restic/excludes.txt" "--exclude-file=${inputs.self}/modules/restic/excludes.txt"
]; ];

View File

@ -1,4 +1,4 @@
{ inputs, ... }: { inputs, custom, ... }:
{ {
programs.steam.enable = true; programs.steam.enable = true;
hardware.steam-hardware.enable = true; hardware.steam-hardware.enable = true;
@ -6,7 +6,7 @@
allowedTCPPorts = [ 27036 ]; allowedTCPPorts = [ 27036 ];
allowedUDPPorts = [ 27031 ]; allowedUDPPorts = [ 27031 ];
}; };
home-manager.users.${inputs.custom.username} = { home-manager.users.${custom.username} = {
home.file.".local/share/applications/steam.desktop".source = ./steam.desktop; home.file.".local/share/applications/steam.desktop".source = ./steam.desktop;
}; };
} }

View File

@ -1,4 +1,4 @@
{ inputs, hostname, ip, ... }: { inputs, custom, hostname, ip, ... }:
{ {
imports = [ imports = [
(import "${inputs.self}/modules/mk-network" { inherit hostname ip; }) (import "${inputs.self}/modules/mk-network" { inherit hostname ip; })