Compare commits
25 Commits
9af4544640
...
8da025f57b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8da025f57b | ||
|
|
3f1a1ea713 | ||
|
|
50141d76a2 | ||
|
|
6ba202edd3 | ||
|
|
e3c29f8ba6 | ||
|
|
c773001a48 | ||
|
|
a5e5f2f1ea | ||
|
|
8039d84347 | ||
|
|
7d28205371 | ||
|
|
902f6ec023 | ||
|
|
fe2dc5b09b | ||
|
|
5d927f10e6 | ||
|
|
a049bd539a | ||
|
|
8b8edf9211 | ||
|
|
e9c54606e2 | ||
|
|
3e15d03778 | ||
|
|
1228151d5a | ||
|
|
b96b9b2409 | ||
|
|
f7735089df | ||
|
|
9432f35ce8 | ||
|
|
e25f7420ff | ||
|
|
c45a48039e | ||
|
|
5d14d515e0 | ||
|
|
0c1e633aaa | ||
|
|
7d4f997c18 |
32
README.md
32
README.md
@@ -12,6 +12,11 @@ home-manager switch --flake .#desktop
|
||||
nix flake show --all-systems
|
||||
```
|
||||
|
||||
## Layout
|
||||
|
||||
- Everything under `./modules` gets auto-imported by `import-tree`
|
||||
-
|
||||
|
||||
## Mechanics
|
||||
|
||||
### Flake
|
||||
@@ -28,7 +33,6 @@ This uses `inputs.flake-parts.lib.mkFlake` to create the flake.
|
||||
|
||||
The modules are automatically imported from the `./modules` using [import-tree](https://import-tree.oeiuwq.com/).
|
||||
|
||||
|
||||
### [Home Manager](https://flake.parts/options/home-manager.html)
|
||||
|
||||
Uses the home-manager module of flake-parts, which is imported in `modules/home-manager/flake-parts.nix`
|
||||
@@ -37,3 +41,29 @@ Looks for options:
|
||||
|
||||
- `flake.homeConfigurations`
|
||||
- `flake.homeModules`
|
||||
|
||||
Show exported home configurations:
|
||||
|
||||
```shell
|
||||
nix eval --apply builtins.attrNames .#homeConfigurations
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
These commands would are useful for debugging
|
||||
|
||||
```shell
|
||||
SYSTEM=lxc
|
||||
|
||||
# Just evaluate (fast, catches config errors)
|
||||
nix eval .#nixosConfigurations.${SYSTEM}.config.system.build.toplevel
|
||||
|
||||
# Full build (slower, produces a bootable system)
|
||||
nix build .#nixosConfigurations.${SYSTEM}.config.system.build.toplevel
|
||||
```
|
||||
|
||||
### Remote Deploy
|
||||
|
||||
```shell
|
||||
nixos-rebuild switch --flake .#lxc --target-host root@fded:fb16:653e:25da:be24:11ff:fea0:753f
|
||||
```
|
||||
|
||||
93
flake.lock
generated
93
flake.lock
generated
@@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"flake-file": {
|
||||
"locked": {
|
||||
"lastModified": 1772863627,
|
||||
"narHash": "sha256-Jx4FIAwp3E1cUKQ+a9DfVhRU+ry/IyjYNJbtyz+ld5U=",
|
||||
"lastModified": 1772999280,
|
||||
"narHash": "sha256-XX60YlqSKa/QNIJVnLeEXNDQPwrQucMuITef6rEJqIs=",
|
||||
"owner": "vic",
|
||||
"repo": "flake-file",
|
||||
"rev": "51181d48fcc08f5cc97b64859b91699d70c59d11",
|
||||
"rev": "e2a19eb539fa7be4537f6e73e7556edf031eed7f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -53,16 +53,34 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681202837,
|
||||
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"home-manager": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1772845525,
|
||||
"narHash": "sha256-Dp5Ir2u4jJDGCgeMRviHvEQDe+U37hMxp6RSNOoMMPc=",
|
||||
"lastModified": 1772985285,
|
||||
"narHash": "sha256-wEEmvfqJcl9J0wyMgMrj1TixOgInBW/6tLPhWGoZE3s=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "27b93804fbef1544cb07718d3f0a451f4c4cd6c0",
|
||||
"rev": "5be5d8245cbc7bc0c09fbb5f38f23f223c543f85",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -73,11 +91,11 @@
|
||||
},
|
||||
"import-tree": {
|
||||
"locked": {
|
||||
"lastModified": 1772344373,
|
||||
"narHash": "sha256-OQQ1MhB9t1J71b2wxRRTdH/Qd8UGG0p+dGspfCf5U1c=",
|
||||
"lastModified": 1772999353,
|
||||
"narHash": "sha256-dPb0WxUhFaz6wuR3B6ysqFJpsu8txKDPZvS47AT2XLI=",
|
||||
"owner": "vic",
|
||||
"repo": "import-tree",
|
||||
"rev": "10fda59eee7d7970ec443b925f32a1bc7526648c",
|
||||
"rev": "545a4df146fce44d155573e47f5a777985acf912",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -109,11 +127,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1772542754,
|
||||
"narHash": "sha256-WGV2hy+VIeQsYXpsLjdr4GvHv5eECMISX1zKLTedhdg=",
|
||||
"lastModified": 1772773019,
|
||||
"narHash": "sha256-E1bxHxNKfDoQUuvriG71+f+s/NT0qWkImXsYZNFFfCs=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "8c809a146a140c5c8806f13399592dbcb1bb5dc4",
|
||||
"rev": "aca4d95fce4914b3892661bcb80b8087293536c6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -136,6 +154,20 @@
|
||||
"url": "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1682134069,
|
||||
"narHash": "sha256-TnI/ZXSmRxQDt2sjRYK/8j8iha4B4zP2cnQCZZ3vp7k=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "fd901ef4bf93499374c5af385b2943f5801c0833",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-file": "flake-file",
|
||||
@@ -147,7 +179,8 @@
|
||||
"nixpkgs-lib": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"sops-nix": "sops-nix"
|
||||
"sops-nix": "sops-nix",
|
||||
"vscode-server": "vscode-server"
|
||||
}
|
||||
},
|
||||
"sops-nix": {
|
||||
@@ -184,6 +217,40 @@
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"vscode-server": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1770124655,
|
||||
"narHash": "sha256-yHmd2B13EtBUPLJ+x0EaBwNkQr9LTne1arLVxT6hSnY=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixos-vscode-server",
|
||||
"rev": "92ce71c3ba5a94f854e02d57b14af4997ab54ef0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixos-vscode-server",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
url = "github:Mic92/sops-nix";
|
||||
};
|
||||
vscode-server.url = "github:nix-community/nixos-vscode-server";
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
12
modules/home-manager/profiles/base.nix
Normal file
12
modules/home-manager/profiles/base.nix
Normal file
@@ -0,0 +1,12 @@
|
||||
{ inputs, pkgs, ... }:
|
||||
{
|
||||
flake.homeModules.base = { pkgs, ... }:
|
||||
{
|
||||
imports = with inputs.self.homeModules; [
|
||||
rebuild
|
||||
ssh
|
||||
git
|
||||
shell-tools
|
||||
];
|
||||
};
|
||||
}
|
||||
12
modules/home-manager/profiles/desktop.nix
Normal file
12
modules/home-manager/profiles/desktop.nix
Normal file
@@ -0,0 +1,12 @@
|
||||
# This module is for programs with GUIs that run in a desktop environment
|
||||
{ inputs, ... }:
|
||||
{
|
||||
flake.homeModules.desktop =
|
||||
{
|
||||
imports = with inputs.self.homeModules; [
|
||||
onepassword
|
||||
ghostty
|
||||
sublime
|
||||
];
|
||||
};
|
||||
}
|
||||
38
modules/home-manager/profiles/shell-tools.nix
Normal file
38
modules/home-manager/profiles/shell-tools.nix
Normal file
@@ -0,0 +1,38 @@
|
||||
# This module provides all the shell options
|
||||
{ inputs, lib, ... }:
|
||||
{
|
||||
flake.homeModules.shell-tools = { config, pkgs, ... }: {
|
||||
options.shell.program = lib.mkOption {
|
||||
type = lib.types.enum [ "bash" "zsh" ];
|
||||
default = "zsh";
|
||||
description = "Which interactive shell configuration to enable.";
|
||||
};
|
||||
|
||||
imports = with inputs.self.homeModules; [
|
||||
bash
|
||||
zsh
|
||||
|
||||
# Tools
|
||||
eza
|
||||
files
|
||||
];
|
||||
|
||||
config = {
|
||||
programs.bash.enable = lib.mkForce (config.shell.program == "bash");
|
||||
programs.zsh.enable = lib.mkForce (config.shell.program == "zsh");
|
||||
home.shell.enableShellIntegration = true;
|
||||
|
||||
home.packages = with pkgs; [
|
||||
wget
|
||||
curl
|
||||
cacert
|
||||
busybox
|
||||
gnugrep
|
||||
dig
|
||||
btop
|
||||
uv
|
||||
xclip
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
flake.homeModules.bash = { pkgs, lib, ... }:
|
||||
flake.homeModules.bash = { pkgs, ... }:
|
||||
{
|
||||
programs.bash = {
|
||||
enable = true;
|
||||
14
modules/home-manager/programs/eza.nix
Normal file
14
modules/home-manager/programs/eza.nix
Normal file
@@ -0,0 +1,14 @@
|
||||
{ inputs, pkgs, lib, ... }:
|
||||
{
|
||||
flake.homeModules.eza = { pkgs, lib, ... }: {
|
||||
programs.eza = {
|
||||
enable = true;
|
||||
package = pkgs.eza;
|
||||
enableBashIntegration = true;
|
||||
enableZshIntegration = true;
|
||||
};
|
||||
home.shellAliases = {
|
||||
ls = "${lib.getExe pkgs.eza} -lgos type --no-time --follow-symlinks";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
home.packages = with pkgs; [
|
||||
gdu
|
||||
lf
|
||||
# TODO: find a CLI file editor that's not insane
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
};
|
||||
|
||||
targets.genericLinux.nixGL = {
|
||||
packages = inputs.nixgl.packages.${pkgs.system};
|
||||
packages = inputs.nixgl.packages.${pkgs.stdenv.hostPlatform.system};
|
||||
defaultWrapper = "mesa";
|
||||
installScripts = [ "mesa" ];
|
||||
};
|
||||
@@ -33,12 +33,14 @@
|
||||
shell-integration-features = [ "no-title" "sudo" ];
|
||||
gtk-single-instance = true;
|
||||
|
||||
window-position-x = 50;
|
||||
window-position-y = 50;
|
||||
window-position-x = 25;
|
||||
window-position-y = 25;
|
||||
# window-height = 40;
|
||||
# window-width = 200;
|
||||
|
||||
window-padding-balance = true;
|
||||
window-padding-x = 5;
|
||||
window-padding-y = 5;
|
||||
# window-padding-balance = true;
|
||||
# window-padding-x = 5;
|
||||
# window-padding-y = 5;
|
||||
initial-window = true;
|
||||
resize-overlay = "never";
|
||||
|
||||
@@ -52,8 +54,6 @@
|
||||
"ctrl+s>k=goto_split:down"
|
||||
];
|
||||
|
||||
window-height = 40;
|
||||
window-width = 200;
|
||||
};
|
||||
};
|
||||
|
||||
5
modules/home-manager/programs/onepassword.nix
Normal file
5
modules/home-manager/programs/onepassword.nix
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
flake.homeModules.onepassword = {
|
||||
# TODO: Port `_1password = true` behavior into an explicit Home Manager module.
|
||||
};
|
||||
}
|
||||
85
modules/home-manager/programs/resticprofile.nix
Normal file
85
modules/home-manager/programs/resticprofile.nix
Normal file
@@ -0,0 +1,85 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
perSystem = { pkgs, ... }:
|
||||
let
|
||||
resticprofilePkg = pkgs.buildGoModule rec {
|
||||
pname = "resticprofile";
|
||||
version = "0.32.0";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "creativeprojects";
|
||||
repo = "resticprofile";
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-fmYsoGYppNgbtoX18aF5UHBG9ieYorBJ9JZkwrR+UBI=";
|
||||
};
|
||||
vendorHash = "sha256-/GVWjOvkYe7xMRjANKIKV6FSU0F5VY1ZP/ppgAJyhvw=";
|
||||
goPackagePath = "github.com/creativeprojects/resticprofile";
|
||||
doCheck = false;
|
||||
meta = with pkgs.lib; {
|
||||
description = "Configuration profiles manager and scheduler for restic backup";
|
||||
homepage = "https://creativeprojects.github.io/resticprofile/";
|
||||
license = licenses.gpl3Only;
|
||||
maintainers = [ ];
|
||||
mainProgram = "resticprofile";
|
||||
};
|
||||
};
|
||||
in {
|
||||
packages = {
|
||||
resticprofile = resticprofilePkg;
|
||||
default = resticprofilePkg;
|
||||
};
|
||||
};
|
||||
|
||||
flake.homeModules.resticprofile = { config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.programs.resticprofile;
|
||||
yamlFormat = pkgs.formats.yaml { };
|
||||
baseProfile = import ../../../resticprofile/base.nix { inherit lib config; };
|
||||
profiles = lib.recursiveUpdate baseProfile cfg.profiles;
|
||||
in {
|
||||
options.programs.resticprofile = {
|
||||
enable = lib.mkEnableOption "Enable resticprofile (Restic backup profile manager)";
|
||||
package = lib.mkPackageOption pkgs "resticprofile" { };
|
||||
profiles = lib.mkOption {
|
||||
type = lib.types.attrsOf yamlFormat.type;
|
||||
default = { };
|
||||
description = ''
|
||||
Additional resticprofile configuration merged on top of the base profile.
|
||||
Each attribute becomes a profile entry in
|
||||
`$XDG_CONFIG_HOME/resticprofile/profiles.yaml`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable (
|
||||
let
|
||||
resticprofilePackage = lib.mkDefault
|
||||
inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.resticprofile;
|
||||
resticprofileBin = lib.getExe cfg.package;
|
||||
rpScript = pkgs.writeShellScriptBin "rp" ''
|
||||
set -e
|
||||
sudo ${resticprofileBin} --config "${config.xdg.configHome}/resticprofile/profiles.yaml" $@
|
||||
'';
|
||||
rpbackupScript = pkgs.writeShellScriptBin "rp-backup" ''
|
||||
${lib.getExe rpScript} run-schedule backup@default
|
||||
'';
|
||||
in {
|
||||
programs.resticprofile.package = resticprofilePackage;
|
||||
home.packages = [
|
||||
cfg.package
|
||||
rpScript
|
||||
rpbackupScript
|
||||
(pkgs.writeShellScriptBin "rps" ''
|
||||
set -e
|
||||
${lib.getExe rpScript} unschedule --all
|
||||
${lib.getExe rpScript} schedule --all
|
||||
'')
|
||||
(pkgs.writeShellScriptBin "rp-test" "${lib.getExe rpbackupScript} --dry-run")
|
||||
];
|
||||
xdg.configFile."resticprofile/profiles.yaml".source = yamlFormat.generate "profiles" {
|
||||
version = "2";
|
||||
profiles = profiles;
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -15,8 +15,8 @@ in
|
||||
flake.homeModules.sops = { inputs, config, pkgs, lib, ... }:
|
||||
let
|
||||
sopsBin = lib.getExe pkgs.sops;
|
||||
sopsConfigPath = ../../.sops.yaml;
|
||||
sopsSecretsPath = ../../keys/secrets.yaml;
|
||||
sopsConfigPath = ../../../.sops.yaml;
|
||||
sopsSecretsPath = ../../../keys/secrets.yaml;
|
||||
ageKeyFile = "${config.xdg.configHome}/sops/age/keys.txt";
|
||||
in
|
||||
{
|
||||
@@ -30,12 +30,12 @@ in
|
||||
echo -n "Created ${ageKeyFile}: "
|
||||
echo $(show-age-key)
|
||||
'')
|
||||
(writeShellScriptBin "show-age-key" "exec ${lib.getExe' pkgs.age "age-keygen"} -y ${ageKeyFile}")
|
||||
(writeShellScriptBin "edit-secrets" "exec ${sopsBin} --config ${sopsConfigPath} ${sopsSecretsPath}")
|
||||
(writeShellScriptBin "ls-secrets" "exec ${lib.getExe pkgs.eza} -alT --follow-symlinks ~/.config/sops-nix/secrets")
|
||||
(writeShellScriptBin "show-age-key" "${lib.getExe' pkgs.age "age-keygen"} -y ${ageKeyFile}")
|
||||
(writeShellScriptBin "edit-secrets" "${sopsBin} --config ${sopsConfigPath} ${sopsSecretsPath}")
|
||||
(writeShellScriptBin "ls-secrets" "${lib.getExe pkgs.eza} -alT --follow-symlinks ~/.config/sops-nix/secrets")
|
||||
];
|
||||
|
||||
programs.zsh.shellAliases.sops = "exec ${sopsBin} --config ${sopsConfigPath}";
|
||||
home.shellAliases.sops = "${sopsBin} --config ${sopsConfigPath}";
|
||||
|
||||
imports = [
|
||||
# This import makes the sops config attribute available below
|
||||
@@ -49,18 +49,16 @@ in
|
||||
# Option definitions for the sops home-manager module:
|
||||
# https://github.com/Mic92/sops-nix/blob/master/modules/home-manager/sops.nix
|
||||
sops = {
|
||||
defaultSopsFile = "${sopsSecretsPath}";
|
||||
defaultSopsFile = sopsSecretsPath;
|
||||
defaultSopsFormat = "yaml";
|
||||
|
||||
# Not sure any of these are necessary
|
||||
# age.sshKeyPaths = [ "${config.sshIdentityFile}" ];
|
||||
age.sshKeyPaths = [ "${config.ssh.IdentityFile}" ];
|
||||
# age.keyFile = "${ageKeyFile}";
|
||||
# age.generateKey = true;
|
||||
|
||||
# secrets."api/gmail_client_secret" = {
|
||||
# path = "${config.xdg.configHome}/resticprofile/dendrite.txt";
|
||||
# };
|
||||
|
||||
secrets."api/gmail_client_secret" = {
|
||||
path = "${config.xdg.configHome}/resticprofile/dendrite.txt";
|
||||
};
|
||||
|
||||
templates."gmail_creds" = {
|
||||
path = "${config.xdg.configHome}/sops-nix/gmail_api_credentials.json";
|
||||
content = ''
|
||||
@@ -17,6 +17,7 @@ in
|
||||
appdaemon = lib.mkEnableOption "Enable AppDaemon SSH targets";
|
||||
certs = lib.mkEnableOption "Enable Janus and Soteria SSH targets";
|
||||
homelab = lib.mkEnableOption "Enable various Homelab targets";
|
||||
dev = lib.mkEnableOption "Enable development targets";
|
||||
};
|
||||
};
|
||||
|
||||
@@ -105,6 +106,13 @@ in
|
||||
user = "panoptes";
|
||||
};
|
||||
})
|
||||
(lib.mkIf config.ssh.matchSets.dev {
|
||||
"test-nix" = {
|
||||
hostname = "fded:fb16:653e:25da:be24:11ff:fea0:753f";
|
||||
user = "john";
|
||||
identityFile = identityFile;
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
5
modules/home-manager/programs/sublime.nix
Normal file
5
modules/home-manager/programs/sublime.nix
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
flake.homeModules.sublime = {
|
||||
# TODO: Port `graphical.sublime = true` into an explicit Home Manager module.
|
||||
};
|
||||
}
|
||||
21
modules/home-manager/programs/vscode.nix
Normal file
21
modules/home-manager/programs/vscode.nix
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
flake.homeModules.vscode = { pkgs, ... }:
|
||||
{
|
||||
programs.vscode = {
|
||||
enable = true;
|
||||
package = pkgs.vscode;
|
||||
profiles.default.extensions = with pkgs.vscode-extensions; [
|
||||
mhutchie.git-graph
|
||||
ms-vscode-remote.vscode-remote-extensionpack
|
||||
ms-python.python
|
||||
ms-python.vscode-pylance
|
||||
ms-toolsai.jupyter
|
||||
charliermarsh.ruff
|
||||
github.vscode-pull-request-github
|
||||
github.vscode-github-actions
|
||||
github.copilot
|
||||
catppuccin.catppuccin-vsc
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
enableCompletion = true;
|
||||
autosuggestion.enable = true;
|
||||
# syntaxHighlighting.enable = true;
|
||||
initContent = "HOST=$(hostname -s)";
|
||||
dotDir = "${config.xdg.configHome}/zsh";
|
||||
history = {
|
||||
append = true;
|
||||
@@ -6,7 +6,7 @@
|
||||
options = {
|
||||
homeManagerFlakeDir = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "~/.config/home-manager/jsl-home";
|
||||
default = "${config.xdg.configHome}/home-manager";
|
||||
description = "Path to the home-manager flake directory.";
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
flake.homeModules.shell = {pkgs, lib, ...}:
|
||||
{
|
||||
imports = with inputs.self.homeModules; [
|
||||
# Shells
|
||||
# bash
|
||||
zsh
|
||||
|
||||
# Tools
|
||||
shell-tools
|
||||
files
|
||||
docker
|
||||
];
|
||||
|
||||
programs.eza = {
|
||||
enable = true;
|
||||
package = pkgs.eza;
|
||||
enableBashIntegration = true;
|
||||
enableZshIntegration = true;
|
||||
};
|
||||
|
||||
home.shell.enableShellIntegration = true;
|
||||
home.shellAliases = {
|
||||
ls = "${lib.getExe pkgs.eza} -lgos type --no-time --follow-symlinks";
|
||||
};
|
||||
};
|
||||
|
||||
flake.homeModules.shell-tools = {pkgs, ...}: {
|
||||
home.packages = with pkgs; [
|
||||
wget
|
||||
curl
|
||||
cacert
|
||||
busybox
|
||||
gnugrep
|
||||
dig
|
||||
btop
|
||||
uv
|
||||
xclip
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
{ inputs, self, ... }:
|
||||
let
|
||||
userName = "john";
|
||||
in
|
||||
{
|
||||
flake.homeModules."${userName}" = {
|
||||
home.username = userName;
|
||||
home.homeDirectory = "/home/${userName}";
|
||||
home.stateVersion = "25.11";
|
||||
|
||||
programs.git.settings.user.name = "John Lancaster";
|
||||
programs.git.settings.user.email = "32917998+jsl12@users.noreply.github.com";
|
||||
};
|
||||
|
||||
flake.modules.nixos.user =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
users.users."${userName}" = {
|
||||
name = "${userName}";
|
||||
shell = pkgs.zsh;
|
||||
};
|
||||
programs.zsh.enable = true;
|
||||
|
||||
home-manager.users."${userName}" = {
|
||||
imports = [
|
||||
inputs.self.homeModules."${userName}"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
35
modules/home-manager/users/john.nix
Normal file
35
modules/home-manager/users/john.nix
Normal file
@@ -0,0 +1,35 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
flake.homeModules.john = {
|
||||
home.username = "john";
|
||||
home.homeDirectory = "/home/john";
|
||||
home.stateVersion = "25.11";
|
||||
xdg.enable = true;
|
||||
|
||||
programs.git.settings.user.name = "John Lancaster";
|
||||
programs.git.settings.user.email = "32917998+jsl12@users.noreply.github.com";
|
||||
|
||||
imports = with inputs.self.homeModules; [
|
||||
base
|
||||
docker
|
||||
# resticprofile
|
||||
];
|
||||
};
|
||||
|
||||
# This is the base homeConfiguration for the john user that will be used if no other
|
||||
flake.homeConfigurations.john = inputs.home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = import inputs.nixpkgs { system = "x86_64-linux"; };
|
||||
modules = [
|
||||
inputs.self.homeModules.john
|
||||
|
||||
# Include another inline module to set the options created through the jsl-home modules
|
||||
{
|
||||
docker.enable = false;
|
||||
ssh.matchSets = {
|
||||
certs = true;
|
||||
homelab = true;
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
60
modules/hosts/john-pc-ubuntu.nix
Normal file
60
modules/hosts/john-pc-ubuntu.nix
Normal file
@@ -0,0 +1,60 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
flake.homeModules."john-pc-ubuntu" = { pkgs, ... }: {
|
||||
imports = with inputs.self.homeModules; [
|
||||
john
|
||||
desktop
|
||||
resticprofile
|
||||
sops
|
||||
];
|
||||
|
||||
home.packages = with pkgs; [
|
||||
nixos-rebuild
|
||||
];
|
||||
# TODO: Add host-specific settings here:
|
||||
# - sops secret for `restic_password/john_ubuntu`
|
||||
# - resticprofile profile definition
|
||||
# - zsh RESTIC* session variables
|
||||
};
|
||||
|
||||
flake.homeConfigurations."john-pc-ubuntu" = inputs.home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = import inputs.nixpkgs { system = "x86_64-linux"; };
|
||||
modules = [
|
||||
inputs.self.homeModules."john-pc-ubuntu"
|
||||
|
||||
# Include another inline module to set the options created through the jsl-home modules
|
||||
({ config, ... }: {
|
||||
homeManagerFlakeDir = "${config.xdg.configHome}/home-manager/jsl-dendritic";
|
||||
docker.enable = true;
|
||||
ssh.matchSets = {
|
||||
certs = true;
|
||||
appdaemon = true;
|
||||
homelab = true;
|
||||
dev = true;
|
||||
};
|
||||
shell.program = "zsh";
|
||||
sops.secrets."restic_password/john_ubuntu" = {
|
||||
path = "${config.xdg.configHome}/resticprofile/password.txt";
|
||||
};
|
||||
programs.resticprofile = {
|
||||
enable= true;
|
||||
profiles = {
|
||||
default = {
|
||||
"inherit" = "base";
|
||||
repository = "rest:https://soteria.john-stream.com/john-ubuntu";
|
||||
cacert = "${config.home.homeDirectory}/.step/certs/root_ca.crt";
|
||||
tls-client-cert = "${config.home.homeDirectory}/.step/certs/mtls.pem";
|
||||
backup = {
|
||||
source = [
|
||||
"${config.xdg.userDirs.documents}"
|
||||
"/conf"
|
||||
];
|
||||
schedule = "*-*-* *:15,30,45:00";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
49
modules/hosts/test-nix.nix
Normal file
49
modules/hosts/test-nix.nix
Normal file
@@ -0,0 +1,49 @@
|
||||
{ inputs, ... }:
|
||||
let
|
||||
name = "test-nix";
|
||||
username = "john";
|
||||
in
|
||||
{
|
||||
flake.modules.nixos."${name}" = { pkgs, lib, ...}: {
|
||||
home-manager.users."${username}" = {
|
||||
imports = [
|
||||
inputs.self.homeModules."${username}"
|
||||
];
|
||||
home.sessionVariables = rec {
|
||||
HOST = "${name}";
|
||||
OTHER_VAR = "abc123";
|
||||
};
|
||||
};
|
||||
|
||||
networking.hostName = "${name}";
|
||||
# environment.sessionVariables = rec {
|
||||
# HOST = "${name}";
|
||||
# };
|
||||
|
||||
users.users."${username}" = {
|
||||
isNormalUser = true;
|
||||
shell = pkgs.zsh;
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIAUa4dcg1TWc4pW++uodyhX4eOqrX/QYIxFWtEP7HFJ john@john-pc-ubuntu"
|
||||
];
|
||||
};
|
||||
programs.zsh.enable = true;
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
# require public key authentication for better security
|
||||
settings.PasswordAuthentication = false;
|
||||
settings.KbdInteractiveAuthentication = false;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
# Generic bootstrapping lxc, use a specific host file for more
|
||||
flake.nixosConfigurations."${name}" = inputs.nixpkgs.lib.nixosSystem {
|
||||
modules = [
|
||||
inputs.home-manager.nixosModules.home-manager
|
||||
inputs.self.modules.nixos.lxc
|
||||
inputs.self.modules.nixos."${name}"
|
||||
];
|
||||
};
|
||||
}
|
||||
12
modules/nixos/games.nix
Normal file
12
modules/nixos/games.nix
Normal file
@@ -0,0 +1,12 @@
|
||||
{ ... }:
|
||||
{
|
||||
flake.modules.nixos.games = {
|
||||
programs.steam = {
|
||||
enable = true;
|
||||
gamescopeSession.enable = true;
|
||||
remotePlay.openFirewall = true;
|
||||
dedicatedServer.openFirewall = true;
|
||||
localNetworkGameTransfers.openFirewall = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
19
modules/nixos/lxc.nix
Normal file
19
modules/nixos/lxc.nix
Normal file
@@ -0,0 +1,19 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
flake.modules.nixos.lxc = { pkgs, lib, ...}: {
|
||||
imports = [
|
||||
({ modulesPath, ... }: { imports = [ "${modulesPath}/virtualisation/proxmox-lxc.nix" ]; })
|
||||
];
|
||||
nixpkgs.hostPlatform = lib.mkForce "x86_64-linux";
|
||||
system.stateVersion = "25.11";
|
||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||
environment.systemPackages = with pkgs; [ git zsh ];
|
||||
};
|
||||
|
||||
# Generic bootstrapping lxc, use a specific host file for more
|
||||
flake.nixosConfigurations.lxc = inputs.nixpkgs.lib.nixosSystem {
|
||||
modules = [
|
||||
inputs.self.modules.nixos.lxc
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
flake.homeModules.desktop =
|
||||
{ pkgs, ... } :
|
||||
{
|
||||
xdg.enable = true;
|
||||
|
||||
imports = with inputs.self.homeModules; [
|
||||
rebuild
|
||||
john
|
||||
ssh
|
||||
git
|
||||
shell
|
||||
ghostty
|
||||
sops
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
flake.homeConfigurations.desktop = inputs.home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = import inputs.nixpkgs { system = "x86_64-linux"; };
|
||||
modules = with inputs.self.homeModules; [
|
||||
desktop
|
||||
];
|
||||
};
|
||||
}
|
||||
51
resticprofile/base.nix
Normal file
51
resticprofile/base.nix
Normal file
@@ -0,0 +1,51 @@
|
||||
{ lib, config, ... }:
|
||||
{
|
||||
base = {
|
||||
repository = "local:/mnt/backup";
|
||||
password-file = "{{ .ConfigDir }}/password.txt";
|
||||
status-file = "{{ .ConfigDir }}/backup-status.json";
|
||||
retention = {
|
||||
after-backup = true;
|
||||
keep-last = "10";
|
||||
keep-hourly = "8";
|
||||
keep-daily = "14";
|
||||
keep-weekly = "8";
|
||||
};
|
||||
backup = {
|
||||
verbose = true;
|
||||
exclude = [
|
||||
".cache"
|
||||
".devenv"
|
||||
".rustup"
|
||||
".cargo"
|
||||
".venv"
|
||||
".pyenv"
|
||||
".vscode*"
|
||||
"data/postgres"
|
||||
"build"
|
||||
"__pycache__"
|
||||
"*.log"
|
||||
"*.egg-info"
|
||||
"*.csv"
|
||||
"*.m4a"
|
||||
|
||||
".local/share/Steam"
|
||||
".local/share/Trash"
|
||||
"build"
|
||||
"dist"
|
||||
"/home/*/Pictures"
|
||||
"/home/*/Videos"
|
||||
"/home/*/go"
|
||||
"/home/*/snap"
|
||||
"/home/john/john-nas"
|
||||
];
|
||||
schedule-permission = "user";
|
||||
schedule-priority = "background";
|
||||
check-after = true;
|
||||
};
|
||||
prune = {
|
||||
schedule-permission = "user";
|
||||
schedule-lock-wait = "1h";
|
||||
};
|
||||
};
|
||||
}
|
||||
29
scripts/inspect.sh
Executable file
29
scripts/inspect.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
NIX_EVAL_CMD="nix eval --json --no-warn-dirty --apply builtins.attrNames"
|
||||
|
||||
list_flake_attr() {
|
||||
attr="$1"
|
||||
flake="${2:-.}"
|
||||
echo "${attr} [${flake}]:"
|
||||
$NIX_EVAL_CMD "${flake}#${attr}" | jq -r '" - " + .[]'
|
||||
echo
|
||||
}
|
||||
|
||||
list_home_modules() {
|
||||
list_flake_attr "homeModules" "$1"
|
||||
}
|
||||
|
||||
list_home_configurations() {
|
||||
list_flake_attr "homeConfigurations" "$1"
|
||||
}
|
||||
|
||||
list_nixos_configurations() {
|
||||
list_flake_attr "nixosConfigurations" "$1"
|
||||
}
|
||||
|
||||
current_dir=$(readlink -f .)
|
||||
flake="${1:-$current_dir}"
|
||||
list_home_modules "$flake"
|
||||
list_home_configurations "$flake"
|
||||
list_nixos_configurations "$flake"
|
||||
24
scripts/switch.sh
Executable file
24
scripts/switch.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
FLAKE_DIR="/home/john/.config/home-manager/jsl-dendritic"
|
||||
|
||||
is_in_array() {
|
||||
local needle="$1"
|
||||
shift
|
||||
local arr=("$@")
|
||||
[[ " ${arr[*]} " == *" ${needle} "* ]] && echo true || echo false
|
||||
}
|
||||
|
||||
hostname_exists() {
|
||||
NIX_EVAL_CMD="nix eval --json --no-warn-dirty --apply builtins.attrNames"
|
||||
mapfile -t HOME_CONFIGS < <(${NIX_EVAL_CMD} ${FLAKE_DIR}#homeConfigurations | jq -r '.[]')
|
||||
is_in_array "$(hostname)" "${HOME_CONFIGS[@]}"
|
||||
}
|
||||
|
||||
HOSTNAME=$(hostname)
|
||||
if [[ "$(hostname_exists)" == "true" ]]; then
|
||||
home-manager switch --flake "${FLAKE_DIR}#${HOSTNAME}"
|
||||
else
|
||||
echo "No homeConfiguration found for hostname '${HOSTNAME}'." >&2
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user