Skip to content

Commit

Permalink
refactor: move username declaration up to flake.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
icecreammatt committed Feb 11, 2024
1 parent 1874e4c commit 3029d78
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 19 deletions.
8 changes: 5 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,22 @@
xremap-flake,
attic,
...
}: {
}: let
user = "matt";
in {
# Gaming PC, Mini, VM, Raspberry Pi
nixosConfigurations = (
import ./hosts/nixos {
inherit (nixpkgs) lib;
inherit inputs nixpkgs nixos-hardware home-manager hyprland sops-nix helix-flake attic;
inherit inputs nixpkgs nixos-hardware home-manager hyprland sops-nix helix-flake attic user;
}
);

# Asahi Linux (M1 Mac)
asahiConfiguration = (
import ./hosts/asahi {
inherit (nixpkgs) lib;
inherit inputs nixpkgs home-manager sops-nix helix-flake;
inherit inputs nixpkgs home-manager sops-nix helix-flake user;
}
);

Expand Down
2 changes: 1 addition & 1 deletion hosts/asahi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ in {
sops-nix.homeManagerModule
{
sops.defaultSopsFormat = "yaml";
sops.age.keyFile = "/home/matt/.config/sops/age/keys.txt";
sops.age.keyFile = "/home/${user}/.config/sops/age/keys.txt";
}
{
# override home manager helix with my fork
Expand Down
8 changes: 6 additions & 2 deletions hosts/nixos/config-common.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{pkgs, ...}: {
{
pkgs,
user,
...
}: {
time.timeZone = "America/Los_Angeles";

users.users.matt = {
users.users.${user} = {
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAmdl6XNEdT+EWf1IDRjHAygUIGpNCaBv9Qhm19cRCEm"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGi7DLE/5v9yI2ZRPeKOftyngeNMvXOX/RDIyA0J3rtI matt@mini"
Expand Down
14 changes: 11 additions & 3 deletions hosts/nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
helix-flake,
sops-nix,
attic,
user,
...
}: let
user = "matt";
in {
}: {
nixos-vm = lib.nixosSystem {
pkgs = import nixpkgs {
system = "aarch64-linux";
Expand All @@ -20,6 +19,9 @@ in {
(import ../../overlay/overlay.nix)
];
};
specialArgs = {
inherit user;
};
modules = [
./config-common.nix
./networking.nix
Expand Down Expand Up @@ -47,6 +49,9 @@ in {
(import ../../overlay/overlay.nix)
];
};
specialArgs = {
inherit user;
};
modules = [
./config-common.nix
./networking.nix
Expand Down Expand Up @@ -116,6 +121,9 @@ in {
(import ../../overlay/overlay.nix)
];
};
specialArgs = {
inherit user;
};
modules = [
nixos-hardware.nixosModules.raspberry-pi-4
./config-common.nix
Expand Down
3 changes: 2 additions & 1 deletion hosts/nixos/mini/kopia.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
pkgs,
config,
user,
...
}: {
environment.systemPackages = with pkgs; [
Expand All @@ -23,7 +24,7 @@
serviceConfig = {
ExecStart = "${pkgs.kopia}/bin/kopia server start --insecure --server-username $USERNAME --server-password $PASSWORD";
Type = "simple";
User = "matt";
User = user;
Group = "users";
EnvironmentFile = [
config.sops.secrets."kopia/PASSWORD".path
Expand Down
8 changes: 4 additions & 4 deletions hosts/nixos/pi4/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{
config,
pkgs,
user,
...
}: let
yazi = pkgs.symlinkJoin {
Expand Down Expand Up @@ -73,7 +74,7 @@ in {
# command = [ "/bin/sh" ];
# args = [ "-c" "echo 'Hello, world!'" ];
volumes = [
"/home/matt/SyncWork/Notes/Notes:/space"
"/home/${user}/SyncWork/Notes/Notes:/space"
];
# restartPolicy = "always";
};
Expand Down Expand Up @@ -117,7 +118,7 @@ in {
services = {
syncthing = {
enable = true;
user = "matt";
user = user;
dataDir = "/mnt/syncthing/personal";
configDir = "/mnt/syncthing/config";
};
Expand Down Expand Up @@ -153,7 +154,7 @@ in {
# services.xserver.libinput.enable = true;

# Define a user account. Don't forget to set a password with ‘passwd’.
# users.users.matt = {
# users.users.${user} = {
# shell = pkgs.fish;
# isNormalUser = true;
# extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
Expand Down Expand Up @@ -186,7 +187,6 @@ in {
services.caddy = {
enable = true;


virtualHosts."pihole.c4er.com".extraConfig = ''
tls /mnt/certs/c4er.com/c4er.com.crt /mnt/certs/c4er.com/c4er.com.key
Expand Down
3 changes: 2 additions & 1 deletion hosts/nixos/vm/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{
config,
pkgs,
user,
...
}: {
imports = [
Expand Down Expand Up @@ -56,7 +57,7 @@
# services.xserver.libinput.enable = true;

# Define a user account. Don't forget to set a password with ‘passwd’.
# users.users.matt = {
# users.users.${user} = {
# shell = pkgs.fish;
# isNormalUser = true;
# extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
Expand Down
5 changes: 3 additions & 2 deletions hosts/nixos/vm2/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{
config,
pkgs,
user,
...
}: {
imports = [
Expand Down Expand Up @@ -81,9 +82,9 @@
# services.xserver.libinput.enable = true;

# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.matt = {
users.users.${user} = {
isNormalUser = true;
description = "matt";
description = user;
extraGroups = ["networkmanager" "wheel"];
packages = with pkgs; [
firefox
Expand Down
3 changes: 1 addition & 2 deletions modules/shell/git.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{user, ...}: let
inherit user;
fullName = "${user.firstName} ${user.lastName}";
#email = user.email;
in {
Expand All @@ -23,7 +22,7 @@ in {
defaultBranch = "main";
};
core = {
excludesfile = "/home/matt/.gitignore_global";
excludesfile = "/home/${user}/.gitignore_global";
autocrlf = "input";
trustctime = false;
pager = "delta";
Expand Down

0 comments on commit 3029d78

Please sign in to comment.