addin ssh key

This commit is contained in:
2023-11-21 14:00:06 +00:00
parent 4178372853
commit 54c3d889ab
33 changed files with 873 additions and 829 deletions

View File

@@ -1,7 +1,12 @@
# This is your system's configuration file. # This is your system's configuration file.
# Use this to configure your system environment (it replaces /etc/nixos/configuration.nix) # Use this to configure your system environment (it replaces /etc/nixos/configuration.nix)
{
{ lib, config, pkgs, modulesPath, ... }: { lib,
config,
pkgs,
modulesPath,
...
}: {
# You can import other NixOS modules here # You can import other NixOS modules here
imports = [ imports = [
@@ -10,10 +15,9 @@
# Include static network settings. # Include static network settings.
./networking.nix ./networking.nix
"${modulesPath}/virtualisation/hyperv-image.nix" "${modulesPath}/virtualisation/hyperv-image.nix"
]; ];
nixpkgs = { config = { allowUnfree = true; }; }; nixpkgs = {config = {allowUnfree = true;};};
nix = { nix = {
settings = { settings = {
@@ -28,12 +32,12 @@
system.stateVersion = "23.05"; system.stateVersion = "23.05";
mymods = { mymods = {
gnome.enable = true; gnome.enable = true;
user_sstent.enable = true; user_sstent.enable = true;
sshd.enable = true; sshd.enable = true;
}; };
networking.firewall.allowedTCPPorts = [ 22 ]; networking.firewall.allowedTCPPorts = [22];
environment.etc."ssh/ssh_host_rsa_key".source = ./ssh/ssh_host_rsa_key; environment.etc."ssh/ssh_host_rsa_key".source = ./ssh/ssh_host_rsa_key;
environment.etc."ssh/ssh_host_rsa_key".mode = "0400"; environment.etc."ssh/ssh_host_rsa_key".mode = "0400";
@@ -41,7 +45,4 @@
environment.etc."ssh/ssh_host_ed25519_key".source = ./ssh/ssh_host_ed25519_key; environment.etc."ssh/ssh_host_ed25519_key".source = ./ssh/ssh_host_ed25519_key;
environment.etc."ssh/ssh_host_ed25519_key".mode = "0400"; environment.etc."ssh/ssh_host_ed25519_key".mode = "0400";
environment.etc."ssh/ssh_host_ed25519_key.pub".source = ./ssh/ssh_host_ed25519_key.pub; environment.etc."ssh/ssh_host_ed25519_key.pub".source = ./ssh/ssh_host_ed25519_key.pub;
} }

View File

@@ -7,33 +7,31 @@
... ...
}: { }: {
# Set your system kind (needed for flakes) # Set your system kind (needed for flakes)
nixpkgs.hostPlatform = "x86_64-linux"; nixpkgs.hostPlatform = "x86_64-linux";
virtualisation.hypervGuest.videoMode = "1920x1080"; virtualisation.hypervGuest.videoMode = "1920x1080";
boot.initrd.availableKernelModules = [ "sd_mod" "sr_mod" ]; boot.initrd.availableKernelModules = ["sd_mod" "sr_mod"];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [];
boot.kernelModules = ["hv_sock"]; boot.kernelModules = ["hv_sock"];
# fileSystems."/" = {
# fileSystems."/" = { # device = "/dev/disk/by-label/nixos";
# device = "/dev/disk/by-label/nixos"; # autoResize = true;
# autoResize = true; # fsType = "ext4";
# fsType = "ext4"; # };
# };
# fileSystems."/boot" = { # fileSystems."/boot" = {
# device = "/dev/disk/by-label/ESP"; # device = "/dev/disk/by-label/ESP";
# fsType = "vfat"; # fsType = "vfat";
# }; # };
fileSystems."/mnt/Public" = {
device = "//192.168.1.109/Public";
fsType = "cifs";
options = let
# this line prevents hanging on network split
automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s";
# in ["${automount_opts},credentials=/etc/nixos/smb-secrets"];
in ["${automount_opts}"];
};
fileSystems."/mnt/Public" = {
device = "//192.168.1.109/Public";
fsType = "cifs";
options = let
# this line prevents hanging on network split
automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s";
# in ["${automount_opts},credentials=/etc/nixos/smb-secrets"];
in ["${automount_opts}"];
};
} }

View File

@@ -1,11 +1,15 @@
{
{ lib, config, pkgs, ... }: { lib,
config,
pkgs,
...
}: {
# You can import other NixOS modules here # You can import other NixOS modules here
hyperv = { hyperv = {
baseImageSize = 8096; baseImageSize = 8096;
}; };
# environment.etc = { # environment.etc = {
# nixos.source = ../..; # nixos.source = ../..;
# }; # };
} }

View File

@@ -21,4 +21,4 @@
]; ];
}; };
}; };
} }

223
flake.nix
View File

@@ -19,10 +19,13 @@
# Shameless plug: looking for a way to nixify your themes and make # Shameless plug: looking for a way to nixify your themes and make
# everything match nicely? Try nix-colors! # everything match nicely? Try nix-colors!
# nix-colors.url = "github:misterio77/nix-colors"; # nix-colors.url = "github:misterio77/nix-colors";
nixos-hardware.url = "github:NixOS/nixos-hardware"; # Import nixos hardware quirks settings nixos-hardware.url = "github:NixOS/nixos-hardware"; # Import nixos hardware quirks settings
# nixos-generators = { url = "github:nix-community/nixos-generators"; inputs.nixpkgs.follows = "nixpkgs";}; #import nixos-generators for building images # nixos-generators = { url = "github:nix-community/nixos-generators"; inputs.nixpkgs.follows = "nixpkgs";}; #import nixos-generators for building images
nixos-wsl = {url = "github:nix-community/nixos-wsl"; inputs.nixpkgs.follows = "nixpkgs";}; nixos-wsl = {
sops-nix.url = github:Mic92/sops-nix; url = "github:nix-community/nixos-wsl";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix.url = github:Mic92/sops-nix;
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
# nix.url = "github:NixOS/nix/2.12.0"; # nix.url = "github:NixOS/nix/2.12.0";
vscode-server.url = "github:msteen/nixos-vscode-server"; vscode-server.url = "github:msteen/nixos-vscode-server";
@@ -45,112 +48,130 @@
# Flake Utility Functions # Flake Utility Functions
utils.url = "github:gytis-ivaskevicius/flake-utils-plus"; utils.url = "github:gytis-ivaskevicius/flake-utils-plus";
}; };
outputs = { self, nixpkgs, home-manager,nixpkgs-unstable,... }@inputs: outputs = {
let self,
inherit (lib.my) mapModules mapModulesRec mapHosts; nixpkgs,
inherit (self) outputs; home-manager,
nixpkgs-unstable,
...
} @ inputs: let
inherit (lib.my) mapModules mapModulesRec mapHosts;
inherit (self) outputs;
system = "x86_64-linux"; system = "x86_64-linux";
mkPkgs = pkgs: extraOverlays: import pkgs { mkPkgs = pkgs: extraOverlays:
import pkgs {
inherit system; inherit system;
config.allowUnfree = true; # forgive me Stallman senpai config.allowUnfree = true; # forgive me Stallman senpai
overlays = extraOverlays ++ (lib.attrValues self.overlays); overlays = extraOverlays ++ (lib.attrValues self.overlays);
}; };
pkgs = mkPkgs nixpkgs [ self.overlay ]; pkgs = mkPkgs nixpkgs [self.overlay];
pkgs' = mkPkgs nixpkgs-unstable []; pkgs' = mkPkgs nixpkgs-unstable [];
lib = nixpkgs.lib.extend lib =
(self: super: { my = import ./lib { inherit pkgs inputs outputs; lib = self; }; }// home-manager.lib); nixpkgs.lib.extend
(self: super:
{
my = import ./lib {
inherit pkgs inputs outputs;
lib = self;
};
}
// home-manager.lib);
in {
lib = lib.my;
packages."${system}" =
mapModules ./pkgs (p: pkgs.callPackage p {});
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra;
in { devShell."${system}" =
lib = lib.my; import ./shell.nix {inherit pkgs;};
packages."${system}" =
mapModules ./pkgs (p: pkgs.callPackage p {});
devShell."${system}" =
import ./shell.nix { inherit pkgs; };
overlay =
final: prev: {
#unstable = pkgs';
my = self.packages."${system}";
};
overlays = import ./overlays { inherit inputs; };
# Output all modules in ./modules to flake. Modules should be in
# individual subdirectories and contain a default.nix file
nixosModules = builtins.listToAttrs (map
(x: {
name = x;
value = import (./modules/nixos + "/${x}");
})
(builtins.attrNames (builtins.readDir ./modules/nixos)));
##import our HM modules
## -- imported in ./home-manger/general
homeManagerModules = builtins.listToAttrs (map
(name: {
inherit name;
value = import (./modules/home-manager + "/${name}");
})
(builtins.attrNames (builtins.readDir ./modules/home-manager)));
# nixosConfigurations =
# mapHosts ./hosts {};
# NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .#your-hostname'
nixosConfigurations = {
go3-wsl = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs lib;hostName = "go3-wsl"; };
modules = [
./hosts/go3-wsl
];
};
StuPC-WSL = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs lib; hostName = "StuPC";};
modules = [
./hosts/StuPC-WSL
];
};
};
# Standalone home-manager configuration entrypoint
# Available through 'home-manager --flake .#your-username@your-hostname'
homeConfigurations = {
# FIXME replace with your username@hostname
"sstent@go3-wsl" = home-manager.lib.homeManagerConfiguration {
# pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
pkgs = pkgs;
extraSpecialArgs = { inherit inputs outputs lib; hostName = "go3-wsl"; };
modules = [
# > Our main home-manager configuration file <
./home-manager/users/sstent
inputs.sops-nix.homeManagerModules.sops
];
};
"sstent@StuPC-WSL" = home-manager.lib.homeManagerConfiguration {
# pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
pkgs = pkgs;
extraSpecialArgs = { inherit inputs outputs lib; hostName = "StuPC-WSL";};
modules = [
# > Our main home-manager configuration file <
./home-manager/users/sstent
inputs.sops-nix.homeManagerModules.sops
];
};
};
overlay = final: prev: {
#unstable = pkgs';
my = self.packages."${system}";
}; };
overlays = import ./overlays {inherit inputs;};
# Output all modules in ./modules to flake. Modules should be in
# individual subdirectories and contain a default.nix file
nixosModules = builtins.listToAttrs (map
(x: {
name = x;
value = import (./modules/nixos + "/${x}");
})
(builtins.attrNames (builtins.readDir ./modules/nixos)));
##import our HM modules
## -- imported in ./home-manger/general
homeManagerModules = builtins.listToAttrs (map
(name: {
inherit name;
value = import (./modules/home-manager + "/${name}");
})
(builtins.attrNames (builtins.readDir ./modules/home-manager)));
# nixosConfigurations =
# mapHosts ./hosts {};
# NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .#your-hostname'
nixosConfigurations = {
go3-wsl = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs outputs lib;
hostName = "go3-wsl";
};
modules = [
./hosts/go3-wsl
];
};
StuPC-WSL = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs outputs lib;
hostName = "StuPC";
};
modules = [
./hosts/StuPC-WSL
];
};
};
# Standalone home-manager configuration entrypoint
# Available through 'home-manager --flake .#your-username@your-hostname'
homeConfigurations = {
# FIXME replace with your username@hostname
"sstent@go3-wsl" = home-manager.lib.homeManagerConfiguration {
# pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
pkgs = pkgs;
extraSpecialArgs = {
inherit inputs outputs lib;
hostName = "go3-wsl";
};
modules = [
# > Our main home-manager configuration file <
./home-manager/users/sstent
inputs.sops-nix.homeManagerModules.sops
];
};
"sstent@StuPC-WSL" = home-manager.lib.homeManagerConfiguration {
# pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
pkgs = pkgs;
extraSpecialArgs = {
inherit inputs outputs lib;
hostName = "StuPC-WSL";
};
modules = [
# > Our main home-manager configuration file <
./home-manager/users/sstent
inputs.sops-nix.homeManagerModules.sops
];
};
};
};
} }

View File

@@ -1,65 +1,65 @@
{ inputs, lib, pkgs, config, outputs, ... }: {
{ inputs,
lib,
imports = [ pkgs,
# ./beets.nix config,
# ./keybase.nix outputs,
"${inputs.vscode-server}/modules/vscode-server/home.nix" ...
] ++ (builtins.attrValues outputs.homeManagerModules); }: {
imports =
[
# ./beets.nix
###dotfiles path variable # ./keybase.nix
options._dotfiles = lib.mkOption { "${inputs.vscode-server}/modules/vscode-server/home.nix"
type = lib.types.str; ]
default = "${inputs.self}/home-manager/dotfiles"; ++ (builtins.attrValues outputs.homeManagerModules);
description = "Path to the dotfiles in this repository";
}; ###dotfiles path variable
options._dotfiles = lib.mkOption {
###secrets path variable type = lib.types.str;
options._secrets = lib.mkOption { default = "${inputs.self}/home-manager/dotfiles";
type = lib.types.str; description = "Path to the dotfiles in this repository";
default = "/run/user/1000/secrets/"; };
description = "Path to the Secrets runtime";
}; ###secrets path variable
options._secrets = lib.mkOption {
type = lib.types.str;
###secretstore path variable default = "/run/user/1000/secrets/";
options._secretstore = lib.mkOption { description = "Path to the Secrets runtime";
type = lib.types.str; };
default = "${inputs.self}/secrets/";
description = "Path to the Secrets storage"; ###secretstore path variable
}; options._secretstore = lib.mkOption {
type = lib.types.str;
config = { default = "${inputs.self}/secrets/";
description = "Path to the Secrets storage";
};
nixpkgs = { config = {
overlays = builtins.attrValues outputs.overlays; nixpkgs = {
config = { overlays = builtins.attrValues outputs.overlays;
allowUnfree = true; config = {
allowUnfreePredicate = (_: true); allowUnfree = true;
}; allowUnfreePredicate = _: true;
}; };
};
nix = {
package = lib.mkDefault pkgs.nix; nix = {
settings = { package = lib.mkDefault pkgs.nix;
experimental-features = [ "nix-command" "flakes" "repl-flake" ]; settings = {
warn-dirty = false; experimental-features = ["nix-command" "flakes" "repl-flake"];
}; warn-dirty = false;
}; };
};
##VSCode
services.vscode-server.enable = true; ##VSCode
services.vscode-server.enableFHS = true; services.vscode-server.enable = true;
services.vscode-server.nodejsPackage = pkgs.nodejs-18_x; services.vscode-server.enableFHS = true;
services.vscode-server.nodejsPackage = pkgs.nodejs-18_x;
programs = { programs = {
home-manager.enable = true; home-manager.enable = true;
git.enable = true; git.enable = true;
}; };
}; };
} }

View File

@@ -1,7 +1,12 @@
{ inputs, outputs, lib, config, pkgs, hostName, ... }:
{ {
inputs,
outputs,
lib,
config,
pkgs,
hostName,
...
}: {
imports = [ imports = [
../../global.nix ../../global.nix
]; ];
@@ -10,7 +15,7 @@
home.stateVersion = "23.05"; home.stateVersion = "23.05";
sops = { sops = {
age.sshKeyPaths = [ "/home/sstent/.ssh/id_ed25519" ]; age.sshKeyPaths = ["/home/sstent/.ssh/id_ed25519"];
defaultSopsFile = "${config._secretstore}/user-secrets.yaml"; defaultSopsFile = "${config._secretstore}/user-secrets.yaml";
secrets = { secrets = {
mrconfig = { mrconfig = {
@@ -18,11 +23,9 @@
format = "binary"; format = "binary";
path = "${config.home.homeDirectory}/.mrconfig"; path = "${config.home.homeDirectory}/.mrconfig";
}; };
}; };
}; };
# home.file."/home/sstent/.config/beets/test".source = config.lib.file.mkOutOfStoreSymlink /run/user/1000/secrets/test; # home.file."/home/sstent/.config/beets/test".source = config.lib.file.mkOutOfStoreSymlink /run/user/1000/secrets/test;
# Let Home Manager install and manage itself. # Let Home Manager install and manage itself.
@@ -33,7 +36,7 @@
bitwarden-cli bitwarden-cli
ansible ansible
# sshpass # sshpass
(import ./python-packages.nix { pkgs = pkgs; }) (import ./python-packages.nix {pkgs = pkgs;})
pyinfra pyinfra
sshpass sshpass
nmap nmap
@@ -73,8 +76,8 @@
yt-dlp.enable = true; yt-dlp.enable = true;
bash = { bash = {
enable = true; enable = true;
historyControl = [ "ignorespace" ]; historyControl = ["ignorespace"];
shellOptions = [ "histappend" ]; shellOptions = ["histappend"];
sessionVariables = { sessionVariables = {
DOCKER_HOST = "tcp://192.168.1.223:2375"; DOCKER_HOST = "tcp://192.168.1.223:2375";
NOMAD_ADDR = "http://192.168.1.250:4646"; NOMAD_ADDR = "http://192.168.1.250:4646";
@@ -84,7 +87,7 @@
PROMPT_COMMAND = "history -a;"; # ensure synchronization between bash memory and history file PROMPT_COMMAND = "history -a;"; # ensure synchronization between bash memory and history file
SSH_AUTH_SOCK = "/home/sstent/.ssh/wsl-ssh-agent.sock"; SSH_AUTH_SOCK = "/home/sstent/.ssh/wsl-ssh-agent.sock";
}; };
bashrcExtra = '' bashrcExtra = ''
if [ -e /home/sstent/.nix-profile/etc/profile.d/nix.sh ]; then . /home/sstent/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer if [ -e /home/sstent/.nix-profile/etc/profile.d/nix.sh ]; then . /home/sstent/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer
# ssh-add -l # ssh-add -l
export PATH=$PATH:/bin #Fix for wslpath export PATH=$PATH:/bin #Fix for wslpath
@@ -95,8 +98,7 @@
enable = true; enable = true;
userName = "sstent"; userName = "sstent";
userEmail = "stuart.stent@gmail.com"; userEmail = "stuart.stent@gmail.com";
extraConfig = { pull.rebase = true; }; extraConfig = {pull.rebase = true;};
}; };
ssh = { ssh = {
enable = true; enable = true;
@@ -114,9 +116,7 @@
}; };
}; };
}; };
} }
#######If Gnome #######If Gnome
# config = lib.mkIf config.mymods.gnome.enable { # config = lib.mkIf config.mymods.gnome.enable {
# programs.bash.enable = true; # programs.bash.enable = true;
@@ -166,7 +166,6 @@
# ]; # ];
# }; # };
# "org/gnome/desktop/interface" = { color-scheme = "prefer-dark"; }; # "org/gnome/desktop/interface" = { color-scheme = "prefer-dark"; };
# }; # };
# }; # };

View File

@@ -1,7 +1,7 @@
{ pkgs }: {pkgs}:
pkgs.python3.withPackages (p:
pkgs.python3.withPackages (p: with p; [ with p; [
requests # HTTP library requests # HTTP library
setuptools # setup.py setuptools # setup.py
paramiko # ssh library paramiko # ssh library
]) ])

View File

@@ -1,9 +1,14 @@
{ lib, pkgs, config, inputs, ... }: { {
lib,
pkgs,
config,
inputs,
...
}: {
imports = [ imports = [
../common.nix ../common.nix
../user-sstent.nix ../user-sstent.nix
inputs.nixos-wsl.nixosModules.wsl inputs.nixos-wsl.nixosModules.wsl
]; ];
# system.stateVersion = "22.11"; # system.stateVersion = "22.11";
@@ -15,6 +20,4 @@
syncthing.enable = true; syncthing.enable = true;
wsl.enable = true; wsl.enable = true;
}; };
} }

View File

@@ -1,81 +1,84 @@
# This file (and the global directory) holds config that i use on all hosts # This file (and the global directory) holds config that i use on all hosts
{ lib, inputs, outputs, pkgs, config, ... }: {
{ lib,
imports = [ inputs,
inputs.home-manager.nixosModules.home-manager outputs,
inputs.sops-nix.nixosModules.sops pkgs,
]++ (builtins.attrValues outputs.nixosModules); config,
...
###dotfiles path variable }: {
options._dotfiles = lib.mkOption { imports =
type = lib.types.str; [
default = "${inputs.self}/home-manager/dotfiles"; inputs.home-manager.nixosModules.home-manager
description = "Path to the dotfiles in this repository"; inputs.sops-nix.nixosModules.sops
}; ]
++ (builtins.attrValues outputs.nixosModules);
###secrets path variable
options._secrets = lib.mkOption { ###dotfiles path variable
type = lib.types.str; options._dotfiles = lib.mkOption {
default = "/run/user/1000/secrets"; type = lib.types.str;
description = "Path to the Secrets runtime"; default = "${inputs.self}/home-manager/dotfiles";
}; description = "Path to the dotfiles in this repository";
};
###secretstore path variable ###secrets path variable
options._secretstore = lib.mkOption { options._secrets = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "${inputs.self}/secrets"; default = "/run/user/1000/secrets";
description = "Path to the Secrets storage"; description = "Path to the Secrets runtime";
}; };
config = { ###secretstore path variable
system.stateVersion = "23.05"; options._secretstore = lib.mkOption {
type = lib.types.str;
default = "${inputs.self}/secrets";
sops = { description = "Path to the Secrets storage";
defaultSopsFile = "${config._secretstore}/host-secrets.yaml"; };
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
}; config = {
system.stateVersion = "23.05";
home-manager = { sops = {
useUserPackages = true; defaultSopsFile = "${config._secretstore}/host-secrets.yaml";
extraSpecialArgs = { inherit inputs outputs; }; age.sshKeyPaths = ["/etc/ssh/ssh_host_ed25519_key"];
sharedModules = [ };
inputs.sops-nix.homeManagerModules.sops
]; home-manager = {
}; useUserPackages = true;
extraSpecialArgs = {inherit inputs outputs;};
nixpkgs.config.allowUnfree = true; sharedModules = [
programs.fuse.userAllowOther = true; inputs.sops-nix.homeManagerModules.sops
security.sudo.wheelNeedsPassword = false; ];
};
# nixpkgs.overlays = overlays;
# Enable nix flakes nixpkgs.config.allowUnfree = true;
nix.package = pkgs.nixFlakes; programs.fuse.userAllowOther = true;
nix.extraOptions = '' security.sudo.wheelNeedsPassword = false;
experimental-features = nix-command flakes
''; # nixpkgs.overlays = overlays;
nix.nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; # Enable nix flakes
# nix.nixPath = [ "nixpkgs=pkgs.outPath" ]; nix.package = pkgs.nixFlakes;
networking.search = ["node.dc1.consul" "service.dc1.consul"]; nix.extraOptions = ''
experimental-features = nix-command flakes
'';
#services.envfs.enable = true; nix.nixPath = ["nixpkgs=${inputs.nixpkgs}"];
environment.systemPackages = [ # nix.nixPath = [ "nixpkgs=pkgs.outPath" ];
pkgs.git networking.search = ["node.dc1.consul" "service.dc1.consul"];
pkgs.home-manager
pkgs.sops #services.envfs.enable = true;
pkgs.ssh-to-age environment.systemPackages = [
pkgs.age pkgs.git
pkgs.bitwarden-cli pkgs.home-manager
]; pkgs.sops
pkgs.ssh-to-age
nix.gc = { pkgs.age
automatic = true; # Enable the automatic garbage collector pkgs.bitwarden-cli
dates = "03:15"; # When to run the garbage collector ];
options = "-d"; # Arguments to pass to nix-collect-garbage
}; nix.gc = {
automatic = true; # Enable the automatic garbage collector
}; dates = "03:15"; # When to run the garbage collector
} options = "-d"; # Arguments to pass to nix-collect-garbage
};
};
}

View File

@@ -1,9 +1,14 @@
{ lib, pkgs, config, inputs, ... }: { {
lib,
pkgs,
config,
inputs,
...
}: {
imports = [ imports = [
../common.nix ../common.nix
../user-sstent.nix ../user-sstent.nix
inputs.nixos-wsl.nixosModules.wsl inputs.nixos-wsl.nixosModules.wsl
]; ];
# system.stateVersion = "22.11"; # system.stateVersion = "22.11";
@@ -16,5 +21,4 @@
syncthing.enable = true; syncthing.enable = true;
wsl.enable = true; wsl.enable = true;
}; };
} }

View File

@@ -1,25 +1,26 @@
{ inputs, lib, config, ... }: {
{ inputs,
lib,
sops.secrets.sstent_password = { config,
#sopsFile = ./secrets.yaml; ...
neededForUsers = true; }: {
}; sops.secrets.sstent_password = {
#sopsFile = ./secrets.yaml;
users.users = { neededForUsers = true;
sstent = { };
# initialPassword = "farscape5";
uid = 1000; users.users = {
passwordFile = config.sops.secrets.sstent_password.path; sstent = {
isNormalUser = true; # initialPassword = "farscape5";
openssh.authorizedKeys.keys = [ uid = 1000;
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+D4o3mL4BQsRr0UIhB1hn0brSTIJ9Lr0m2fMMVGF3tIuEihnmwGTeAX78q5/bmoo4gZy7G+CHal54S1lY8LY1KvmIDCpPJ8848HvLbTiTX3qZ7Mjaav+Ox9eHMwX+7zkPwdhfP8TDvmNe12j1GEKBhAm+FhdBQCbEV7cbm1SkX0+WBGoVvI2qbRm1RF0mOuTAmO3Lr2YeAcKJ21YxwNMv1Qrj7oxGYH9rLHLNwZ/0soIdTC9cikl4DHyvCs4HRYcVw36uuCVc/AyIT2GeETRapAQr8nzT89Haa1IThgZ9ztjSsSSOtrUhxatlMIfTIpVjl/gWq7GLfqd/ei/evTal sstent@StuPC" passwordFile = config.sops.secrets.sstent_password.path;
]; isNormalUser = true;
extraGroups = [ "wheel" "video" ]; openssh.authorizedKeys.keys = [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+D4o3mL4BQsRr0UIhB1hn0brSTIJ9Lr0m2fMMVGF3tIuEihnmwGTeAX78q5/bmoo4gZy7G+CHal54S1lY8LY1KvmIDCpPJ8848HvLbTiTX3qZ7Mjaav+Ox9eHMwX+7zkPwdhfP8TDvmNe12j1GEKBhAm+FhdBQCbEV7cbm1SkX0+WBGoVvI2qbRm1RF0mOuTAmO3Lr2YeAcKJ21YxwNMv1Qrj7oxGYH9rLHLNwZ/0soIdTC9cikl4DHyvCs4HRYcVw36uuCVc/AyIT2GeETRapAQr8nzT89Haa1IThgZ9ztjSsSSOtrUhxatlMIfTIpVjl/gWq7GLfqd/ei/evTal sstent@StuPC"
}; ];
}; extraGroups = ["wheel" "video"];
};
# home-manager.users.misterio = import home/${config.networking.hostName}.nix; };
} # home-manager.users.misterio = import home/${config.networking.hostName}.nix;
}

View File

@@ -1,11 +1,9 @@
{ lib, ... }: {lib, ...}:
with builtins; with builtins;
with lib; with lib; rec {
rec {
# attrsToList # attrsToList
attrsToList = attrs: attrsToList = attrs:
mapAttrsToList (name: value: { inherit name value; }) attrs; mapAttrsToList (name: value: {inherit name value;}) attrs;
# mapFilterAttrs :: # mapFilterAttrs ::
# (name -> value -> bool) # (name -> value -> bool)

View File

@@ -1,33 +1,37 @@
# {lib}: # {lib}:
# lib.makeExtensible (self: # lib.makeExtensible (self:
# let # let
# callLibs = file: import file { lib = self; }; # callLibs = file: import file { lib = self; };
# in # in
# rec { # rec {
# ## Define your own library functions here! # ## Define your own library functions here!
# #id = x: x; # #id = x: x;
# ## Or in files, containing functions that take {lib} # ## Or in files, containing functions that take {lib}
# map = callLibs ./map.nix; # map = callLibs ./map.nix;
# ## In configs, they can be used under "lib.our" # ## In configs, they can be used under "lib.our"
# }) # })
{
inputs,
lib,
{ inputs, lib, pkgs, ... }: pkgs,
...
let }: let
inherit (lib) makeExtensible attrValues foldr; inherit (lib) makeExtensible attrValues foldr;
inherit (modules) mapModules; inherit (modules) mapModules;
modules = import ./modules.nix { modules = import ./modules.nix {
inherit lib; inherit lib;
self.attrs = import ./attrs.nix { inherit lib; self = {}; }; self.attrs = import ./attrs.nix {
}; inherit lib;
self = {};
mylib = makeExtensible (self: };
with self; mapModules ./. };
(file: import file { inherit self lib pkgs inputs; }));
in mylib = makeExtensible (self:
mylib.extend with self;
(self: super: mapModules ./.
foldr (a: b: a // b) {} (attrValues super)) (file: import file {inherit self lib pkgs inputs;}));
in
mylib.extend
(self: super:
foldr (a: b: a // b) {} (attrValues super))

View File

@@ -1,30 +1,32 @@
{ lib, pkgs, ... }:
with builtins;
with lib;
{ {
toCSSFile = file: lib,
let fileName = removeSuffix ".scss" (baseNameOf file); pkgs,
compiledStyles = ...
pkgs.runCommand "compileScssFile" }:
{ buildInputs = [ pkgs.sass ]; } '' with builtins;
mkdir "$out" with lib; {
scss --sourcemap=none \ toCSSFile = file: let
--no-cache \ fileName = removeSuffix ".scss" (baseNameOf file);
--style compressed \ compiledStyles =
--default-encoding utf-8 \ pkgs.runCommand "compileScssFile"
"${file}" \ {buildInputs = [pkgs.sass];} ''
>>"$out/${fileName}.css" mkdir "$out"
''; scss --sourcemap=none \
in "${compiledStyles}/${fileName}.css"; --no-cache \
--style compressed \
--default-encoding utf-8 \
"${file}" \
>>"$out/${fileName}.css"
'';
in "${compiledStyles}/${fileName}.css";
toFilteredImage = imageFile: options: toFilteredImage = imageFile: options: let
let result = "result.png"; result = "result.png";
filteredImage = filteredImage =
pkgs.runCommand "filterWallpaper" pkgs.runCommand "filterWallpaper"
{ buildInputs = [ pkgs.imagemagick ]; } '' {buildInputs = [pkgs.imagemagick];} ''
mkdir "$out" mkdir "$out"
convert ${options} ${imageFile} $out/${result} convert ${options} ${imageFile} $out/${result}
''; '';
in "${filteredImage}/${result}"; in "${filteredImage}/${result}";
} }

View File

@@ -1,32 +1,30 @@
{lib, ...}: let {lib, ...}: let
inherit inherit
(builtins) (builtins)
readDir readDir
; ;
inherit inherit
(lib) (lib)
filterAttrs filterAttrs
hasPrefix hasPrefix
hasSuffix hasSuffix
mapAttrs' mapAttrs'
nameValuePair nameValuePair
;
; in rec {
in rec { filter = name: func: attrs: filterAttrs name (mapAttrs' func attrs);
filter = name: func: attrs: filterAttrs name (mapAttrs' func attrs);
# 'sops' Encrypted Secrets
# 'sops' Encrypted Secrets hm_secrets = dir: out_dir:
hm_secrets = dir: out_dir: filter (name: type: type != null && !(hasPrefix "_" name)) (name: type:
filter (name: type: type != null && !(hasPrefix "_" name)) (name: type: # if type == "regular" && hasSuffix ".age" name
# if type == "regular" && hasSuffix ".age" name if type == "regular"
if type == "regular" then
then nameValuePair name {
nameValuePair name { sopsFile = dir + "/${name}";
sopsFile = dir + "/${name}"; format = "binary";
format = "binary"; path = out_dir + "/${name}";
path = out_dir + "/${name}"; }
else nameValuePair "" null) (readDir dir);
} }
else nameValuePair "" null) (readDir dir);
}

View File

@@ -1,53 +1,60 @@
{ self, lib, ... }: {
self,
let lib,
...
}: let
inherit (builtins) attrValues readDir pathExists concatLists; inherit (builtins) attrValues readDir pathExists concatLists;
inherit (lib) id mapAttrsToList filterAttrs hasPrefix hasSuffix nameValuePair removeSuffix; inherit (lib) id mapAttrsToList filterAttrs hasPrefix hasSuffix nameValuePair removeSuffix;
inherit (self.attrs) mapFilterAttrs; inherit (self.attrs) mapFilterAttrs;
in in rec {
rec {
mapModules = dir: fn: mapModules = dir: fn:
mapFilterAttrs mapFilterAttrs
(n: v: (n: v:
v != null && v
!(hasPrefix "_" n)) != null
(n: v: && !(hasPrefix "_" n))
let path = "${toString dir}/${n}"; in (n: v: let
if v == "directory" && pathExists "${path}/default.nix" path = "${toString dir}/${n}";
then nameValuePair n (fn path) in
else if v == "regular" && if v == "directory" && pathExists "${path}/default.nix"
n != "default.nix" && then nameValuePair n (fn path)
hasSuffix ".nix" n else if
then nameValuePair (removeSuffix ".nix" n) (fn path) v
else nameValuePair "" null) == "regular"
(readDir dir); && n != "default.nix"
&& hasSuffix ".nix" n
then nameValuePair (removeSuffix ".nix" n) (fn path)
else nameValuePair "" null)
(readDir dir);
mapModules' = dir: fn: mapModules' = dir: fn:
attrValues (mapModules dir fn); attrValues (mapModules dir fn);
mapModulesRec = dir: fn: mapModulesRec = dir: fn:
mapFilterAttrs mapFilterAttrs
(n: v: (n: v:
v != null && v
!(hasPrefix "_" n)) != null
(n: v: && !(hasPrefix "_" n))
let path = "${toString dir}/${n}"; in (n: v: let
if v == "directory" path = "${toString dir}/${n}";
then nameValuePair n (mapModulesRec path fn) in
else if v == "regular" && n != "default.nix" && hasSuffix ".nix" n if v == "directory"
then nameValuePair (removeSuffix ".nix" n) (fn path) then nameValuePair n (mapModulesRec path fn)
else nameValuePair "" null) else if v == "regular" && n != "default.nix" && hasSuffix ".nix" n
(readDir dir); then nameValuePair (removeSuffix ".nix" n) (fn path)
else nameValuePair "" null)
(readDir dir);
mapModulesRec' = dir: fn: mapModulesRec' = dir: fn: let
let dirs =
dirs = mapAttrsToList
mapAttrsToList (k: _: "${dir}/${k}")
(k: _: "${dir}/${k}") (filterAttrs
(filterAttrs (n: v: v == "directory" && !(hasPrefix "_" n))
(n: v: v == "directory" && !(hasPrefix "_" n)) (readDir dir));
(readDir dir)); files = attrValues (mapModules dir id);
files = attrValues (mapModules dir id); paths = files ++ concatLists (map (d: mapModulesRec' d id) dirs);
paths = files ++ concatLists (map (d: mapModulesRec' d id) dirs); in
in map fn paths; map fn paths;
} }

View File

@@ -1,25 +1,29 @@
{ inputs, lib, pkgs, ... }: {
inputs,
lib,
pkgs,
...
}:
with lib; with lib;
with lib.my; with lib.my; let
let sys = "x86_64-linux"; sys = "x86_64-linux";
in { in {
mkHost = path: attrs @ { system ? sys, ... }: mkHost = path: attrs @ {system ? sys, ...}:
nixosSystem { nixosSystem {
inherit system; inherit system;
specialArgs = { inherit lib inputs system; }; specialArgs = {inherit lib inputs system;};
modules = [ modules = [
{ {
nixpkgs.pkgs = pkgs; nixpkgs.pkgs = pkgs;
networking.hostName = mkDefault (removeSuffix ".nix" (baseNameOf path)); networking.hostName = mkDefault (removeSuffix ".nix" (baseNameOf path));
} }
(filterAttrs (n: v: !elem n [ "system" ]) attrs) (filterAttrs (n: v: !elem n ["system"]) attrs)
../. # /default.nix ../. # /default.nix
(import path) (import path)
]; ];
}; };
mapHosts = dir: attrs @ { system ? system, ... }: mapHosts = dir: attrs @ {system ? system, ...}:
mapModules dir mapModules dir
(hostPath: mkHost hostPath attrs); (hostPath: mkHost hostPath attrs);
} }

View File

@@ -1,18 +1,16 @@
{ lib, ... }: {lib, ...}: let
let
inherit (lib) mkOption types; inherit (lib) mkOption types;
in in rec {
rec { mkOpt = type: default:
mkOpt = type: default: mkOption {inherit type default;};
mkOption { inherit type default; };
mkOpt' = type: default: description: mkOpt' = type: default: description:
mkOption { inherit type default description; }; mkOption {inherit type default description;};
mkBoolOpt = default: mkOption { mkBoolOpt = default:
inherit default; mkOption {
type = types.bool; inherit default;
example = true; type = types.bool;
}; example = true;
};
} }

View File

@@ -1,7 +1,11 @@
{ config, pkgs, lib, ... }: {
with lib; config,
pkgs,
let cfg = config.custom.beets; lib,
...
}:
with lib; let
cfg = config.custom.beets;
in { in {
options.custom.beets = { options.custom.beets = {
enable = mkOption { enable = mkOption {
@@ -16,13 +20,12 @@ in {
pkgs.ffmpeg # for replaygain pkgs.ffmpeg # for replaygain
]; ];
sops = {
sops = { secrets.discogs_json = {
secrets.discogs_json = { path = "${config.xdg.configHome}/beets/discogs_token.json";
path = "${config.xdg.configHome}/beets/discogs_token.json"; };
}; };
}; programs.beets = {
programs.beets = {
enable = true; enable = true;
settings = { settings = {
album_fields = { album_fields = {
@@ -48,12 +51,12 @@ in {
bracket = "[]"; bracket = "[]";
ignore_va = "compilation"; ignore_va = "compilation";
types = [ types = [
{ ep = "EP"; } {ep = "EP";}
{ single = "Single"; } {single = "Single";}
{ soundtrack = "OST"; } {soundtrack = "OST";}
{ live = "Live"; } {live = "Live";}
{ compilation = "Anthology"; } {compilation = "Anthology";}
{ remix = "Remix"; } {remix = "Remix";}
]; ];
}; };
aunique = { aunique = {
@@ -61,9 +64,9 @@ in {
disambiguators = "media"; disambiguators = "media";
keys = "albumartist album"; keys = "albumartist album";
}; };
copyartifacts = { extensions = ".cue .log .jpg .jpeg .png .txt"; }; copyartifacts = {extensions = ".cue .log .jpg .jpeg .png .txt";};
directory = "/mnt/q/CleanMusic/"; directory = "/mnt/q/CleanMusic/";
embedart = { auto = true; }; embedart = {auto = true;};
extrafiles = { extrafiles = {
paths = { paths = {
artworkdir = "$albumpath/Artwork"; artworkdir = "$albumpath/Artwork";
@@ -73,7 +76,7 @@ in {
}; };
patterns = { patterns = {
all = "*.*"; all = "*.*";
artworkdir = [ "[sS]cans/" "[aA]rtwork/" "[aA]rt/" "[cC]over/" ]; artworkdir = ["[sS]cans/" "[aA]rtwork/" "[aA]rt/" "[cC]over/"];
}; };
}; };
fetchart = { fetchart = {
@@ -93,8 +96,7 @@ in {
isMultidisc = "1 if disctotal > 1 else 0"; isMultidisc = "1 if disctotal > 1 else 0";
myBitDepth = "('' if bitdepth != 24 else '[24bit - '+ media + ']')"; myBitDepth = "('' if bitdepth != 24 else '[24bit - '+ media + ']')";
myDisc = "('' if disctotal <= 1 else str(disc) + ' - ')"; myDisc = "('' if disctotal <= 1 else str(disc) + ' - ')";
mySongartist = mySongartist = "artist + ' - ' if artist != albumartist and artist != '' else ''";
"artist + ' - ' if artist != albumartist and artist != '' else ''";
}; };
library = "~/musiclibrary.db"; library = "~/musiclibrary.db";
match = { match = {
@@ -123,8 +125,7 @@ in {
}; };
missing = { missing = {
format_album = "$albumartist: ($year) $album $albumtype $atype"; format_album = "$albumartist: ($year) $album $albumtype $atype";
format_item = format_item = "$albumartist - $album [$albumtype]$atype: $track/$tracktotal $title";
"$albumartist - $album [$albumtype]$atype: $track/$tracktotal $title";
}; };
musicbrainz = { musicbrainz = {
pass = "7ANCLPczDNFn6Sf65vdZ"; pass = "7ANCLPczDNFn6Sf65vdZ";
@@ -132,12 +133,9 @@ in {
}; };
original_date = true; original_date = true;
paths = { paths = {
"albumtype:soundtrack" = "albumtype:soundtrack" = "Soundtracks/$albumartist - $album%aunique{} ($year)/$myDisc$track - $artist - $title";
"Soundtracks/$albumartist - $album%aunique{} ($year)/$myDisc$track - $artist - $title"; comp = "Compilations/$albumartist/($year) $album%aunique{}/$myDisc$track - $artist - $title";
comp = default = "%if{$artist_grouping,$artist_grouping/}$first_artist/$year - $album $atype%aunique{media}[%upper{$format}$bitdepth]%if{$media,[$media]}/%if{$isMultidisc,$disc - }$track - $mySongartist$title";
"Compilations/$albumartist/($year) $album%aunique{}/$myDisc$track - $artist - $title";
default =
"%if{$artist_grouping,$artist_grouping/}$first_artist/$year - $album $atype%aunique{media}[%upper{$format}$bitdepth]%if{$media,[$media]}/%if{$isMultidisc,$disc - }$track - $mySongartist$title";
}; };
per_disc_numbering = true; per_disc_numbering = true;
plugins = [ plugins = [
@@ -154,25 +152,21 @@ in {
"replaygain" "replaygain"
"info" "info"
]; ];
replaygain = { replaygain = {
backend = "ffmpeg"; backend = "ffmpeg";
}; };
rewrite = { rewrite = {
"artist Björk & Tríó Guðmundar Ingólfssonar" = "Björk"; "artist Björk & Tríó Guðmundar Ingólfssonar" = "Björk";
"artist Brant Bjork and The Low Desert Punk Band" = "Brant Bjork"; "artist Brant Bjork and The Low Desert Punk Band" = "Brant Bjork";
"artist King Gizzard & The Lizard Wizard with Mild High Club" = "artist King Gizzard & The Lizard Wizard with Mild High Club" = "King Gizzard & The Lizard Wizard";
"King Gizzard & The Lizard Wizard";
"artist Kyuss _ Queens of the Stone Age" = "Kyuss"; "artist Kyuss _ Queens of the Stone Age" = "Kyuss";
"artist Professor Elemental & Tom Caruana" = "Professor Elemental"; "artist Professor Elemental & Tom Caruana" = "Professor Elemental";
"artist Resin Dogs Feat Spikey Tee" = "Resin Dogs"; "artist Resin Dogs Feat Spikey Tee" = "Resin Dogs";
"artist Sepultura _ Exodus" = "Sepultura"; "artist Sepultura _ Exodus" = "Sepultura";
"artist The Knife in collaboration with Mount Sims and Planningtorock" = "artist The Knife in collaboration with Mount Sims and Planningtorock" = "The Knife";
"The Knife";
"artist Unida _ Dozer" = "Unida"; "artist Unida _ Dozer" = "Unida";
}; };
}; };
}; };
}; };
} }

View File

@@ -1,11 +1,17 @@
{ config, pkgs, inputs, lib, util, hostName, ... }: {
config,
pkgs,
inputs,
lib,
util,
hostName,
...
}:
with lib; with lib;
with lib.my; with lib.my; let
let cfg = config.custom.keybase;
cfg = config.custom.keybase; username = config.home.username;
username = config.home.username; secretstore = config._secretstore;
secretstore = config._secretstore;
in { in {
options.custom.keybase = { options.custom.keybase = {
enable = mkOption { enable = mkOption {
@@ -15,16 +21,14 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
services.keybase.enable = true; services.keybase.enable = true;
services.kbfs.enable = true; services.kbfs.enable = true;
systemd.user.services.keybase.Unit.After = [ "sops-nix.service" ]; systemd.user.services.keybase.Unit.After = ["sops-nix.service"];
systemd.user.services.kbfs.Unit.After = [ "sops-nix.service" ]; systemd.user.services.kbfs.Unit.After = ["sops-nix.service"];
sops = { sops = {
secrets = hm_secrets "${secretstore}/user_dotfiles/${username}@${hostName}/keybase/" "${config.xdg.configHome}/keybase/"; secrets = hm_secrets "${secretstore}/user_dotfiles/${username}@${hostName}/keybase/" "${config.xdg.configHome}/keybase/";
}; };
}; };
} }

View File

@@ -1,7 +1,11 @@
{ lib, pkgs, config, ... }: {
with lib; lib,
pkgs,
let cfg = config.custom.ssh-proxy; config,
...
}:
with lib; let
cfg = config.custom.ssh-proxy;
in { in {
options.custom.ssh-proxy = { options.custom.ssh-proxy = {
enable = mkOption { enable = mkOption {
@@ -14,31 +18,28 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = with pkgs; [ home.packages = with pkgs; [
npiperelay npiperelay
socat socat
]; ];
systemd.user = {
startServices = true;
systemd.user = { services.ssh-proxy = {
Unit = {
startServices = true; Description = "WSL Proxy";
After = "sops-nix.service";
services.ssh-proxy = { };
Unit = { Description = "WSL Proxy"; After = "sops-nix.service";}; Install = {WantedBy = ["default.target"];};
Install = { WantedBy = [ "default.target" ]; }; Service = {
Service = { ExecStart = "${pkgs.writeShellScript "start-proxy" ''
ExecStart = "${pkgs.writeShellScript "start-proxy" '' set -x -o xtrace # print commands
set -x -o xtrace # print commands ${pkgs.coreutils}/bin/rm -f /home/sstent/.ssh/wsl-ssh-agent.sock
${pkgs.coreutils}/bin/rm -f /home/sstent/.ssh/wsl-ssh-agent.sock ${pkgs.util-linux}/bin/setsid ${pkgs.socat}/bin/socat UNIX-LISTEN:/home/sstent/.ssh/wsl-ssh-agent.sock,fork EXEC:"${pkgs.npiperelay}/bin/npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork
${pkgs.util-linux}/bin/setsid ${pkgs.socat}/bin/socat UNIX-LISTEN:/home/sstent/.ssh/wsl-ssh-agent.sock,fork EXEC:"${pkgs.npiperelay}/bin/npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork ''}";
''}"; };
};
}; };
}; };
}; }
};
}

View File

@@ -1,19 +1,21 @@
{ lib, inputs, outputs, config, ... }: {
with lib; lib,
inputs,
let cfg = config.custom.mnt_public; outputs,
in { config,
options.custom.mnt_public.enable = mkEnableOption "Enable mnt/Public"; ...
}:
config = mkIf cfg.enable { with lib; let
cfg = config.custom.mnt_public;
in {
fileSystems."/mnt/Public" = { options.custom.mnt_public.enable = mkEnableOption "Enable mnt/Public";
device = "//192.168.1.109/Public";
fsType = "cifs"; config = mkIf cfg.enable {
# options = ["uid=0,gid=1000"]; fileSystems."/mnt/Public" = {
options = ["guest" "uid=1000"]; device = "//192.168.1.109/Public";
}; fsType = "cifs";
}; # options = ["uid=0,gid=1000"];
} options = ["guest" "uid=1000"];
};
};
}

View File

@@ -1,20 +1,22 @@
{ lib, pkgs, config, ... }: {
with lib; lib,
pkgs,
let cfg = config.custom.sshd; config,
...
}:
with lib; let
cfg = config.custom.sshd;
in { in {
#define option to enable this
#define option to enable this
options.custom.sshd.enable = mkEnableOption "Enable SSH"; options.custom.sshd.enable = mkEnableOption "Enable SSH";
config = mkIf cfg.enable { config = mkIf cfg.enable {
services.openssh = { services.openssh = {
enable = true; enable = true;
permitRootLogin = "no"; permitRootLogin = "no";
passwordAuthentication = false; passwordAuthentication = false;
}; };
networking.firewall.allowedTCPPorts = [ 22 ]; networking.firewall.allowedTCPPorts = [22];
};
}; }
}

View File

@@ -1,33 +1,37 @@
{ lib, inputs, outputs, config, ... }: {
with lib; lib,
inputs,
let cfg = config.custom.syncthing; outputs,
in { config,
options.custom.syncthing.enable = mkEnableOption "Enable mnt/Public"; ...
}:
config = mkIf cfg.enable { with lib; let
cfg = config.custom.syncthing;
services.syncthing = { in {
enable = true; options.custom.syncthing.enable = mkEnableOption "Enable mnt/Public";
dataDir = "/home/sstent";
openDefaultPorts = true; config = mkIf cfg.enable {
configDir = "/home/sstent/.config/syncthing"; services.syncthing = {
user = "sstent"; enable = true;
group = "users"; dataDir = "/home/sstent";
guiAddress = "0.0.0.0:8385"; openDefaultPorts = true;
configDir = "/home/sstent/.config/syncthing";
overrideDevices = true; user = "sstent";
overrideFolders = true; group = "users";
devices = { guiAddress = "0.0.0.0:8385";
"StuPC" = { id = "Z43MPGF-OKG6K34-WTTFUDO-UG6E3TE-YCLSOAT-5LN5KMW-QHL2VSK-EZCGCAP"; };
"go3" = { id = "YDOL433-AHAL33M-NWLLDDQ-2D36ZIE-YNZVTKE-25TRBZ2-JXRSN7Y-Z5EOVQN"; }; overrideDevices = true;
}; overrideFolders = true;
folders = { devices = {
"default" = { "StuPC" = {id = "Z43MPGF-OKG6K34-WTTFUDO-UG6E3TE-YCLSOAT-5LN5KMW-QHL2VSK-EZCGCAP";};
path = "/home/sstent/sync"; "go3" = {id = "YDOL433-AHAL33M-NWLLDDQ-2D36ZIE-YNZVTKE-25TRBZ2-JXRSN7Y-Z5EOVQN";};
devices = [ "StuPC" "go3" ]; };
}; folders = {
}; "default" = {
}; path = "/home/sstent/sync";
}; devices = ["StuPC" "go3"];
} };
};
};
};
}

View File

@@ -1,41 +1,38 @@
{ lib, pkgs, config, ... }: {
with lib; lib,
pkgs,
config,
...
}:
with lib; let
secretstore = config._secretstore;
host = config.networking.hostName;
let cfg = config.custom.mullvad;
secretstore = config._secretstore;
host = config.networking.hostName;
cfg = config.custom.mullvad;
secret = if builtins.pathExists "${secretstore}/hosts/${host}/mullvad/device.json" then
./secrets.nix
else
{ };
secret =
if builtins.pathExists "${secretstore}/hosts/${host}/mullvad/device.json"
then ./secrets.nix
else {};
in { in {
#define option to enable this
#define option to enable this
options.custom.mullvad.enable = mkEnableOption "Enable SSH"; options.custom.mullvad.enable = mkEnableOption "Enable SSH";
# imports = [ secret ]; # imports = [ secret ];
config = mkIf cfg.enable { config = mkIf cfg.enable {
networking.wireguard.enable = true; networking.wireguard.enable = true;
services.mullvad-vpn.enable = true; services.mullvad-vpn.enable = true;
# set some options after every daemon start # set some options after every daemon start
# to avoid accidentally leaving unsafe settings # to avoid accidentally leaving unsafe settings
systemd.services."mullvad-daemon" = { systemd.services."mullvad-daemon" = {
postStart = '' postStart = ''
while ! ${pkgs.mullvad}/bin/mullvad status >/dev/null; do sleep 1; done while ! ${pkgs.mullvad}/bin/mullvad status >/dev/null; do sleep 1; done
${pkgs.mullvad}/bin/mullvad lan set allow #enable local lan access ${pkgs.mullvad}/bin/mullvad lan set allow #enable local lan access
${pkgs.mullvad}/bin/mullvad relay set tunnel-protocol wireguard ${pkgs.mullvad}/bin/mullvad relay set tunnel-protocol wireguard
${pkgs.mullvad}/bin/mullvad relay set location ca mtr ${pkgs.mullvad}/bin/mullvad relay set location ca mtr
''; '';
};
}; };
}
};
}

View File

@@ -1,23 +1,18 @@
{ lib, pkgs, config, ... }: {
with lib; lib,
pkgs,
let config,
secretstore = config._secretstore; ...
host = config.networking.hostName; }:
secretpath = "${secretstore}/hosts/${host}/mullvad/device.json"; with lib; let
secretstore = config._secretstore;
in { host = config.networking.hostName;
secretpath = "${secretstore}/hosts/${host}/mullvad/device.json";
in {
sops.secrets.device_json= { sops.secrets.device_json = {
sopsFile = "${secretstore}/hosts/${host}/mullvad/device.json"; sopsFile = "${secretstore}/hosts/${host}/mullvad/device.json";
device_json.format = "binary"; device_json.format = "binary";
}; };
environment.etc."mullvad-vpn/device.conf".source = config.sops.secrets.device_json.path; environment.etc."mullvad-vpn/device.conf".source = config.sops.secrets.device_json.path;
}
}

View File

@@ -1,56 +1,57 @@
{ lib, inputs, outputs, config, pkgs, ... }: {
with lib; lib,
inputs,
let cfg = config.custom.wsl; outputs,
in { config,
options.custom.wsl.enable = mkEnableOption "Enable WSL2 settings"; pkgs,
...
config = mkIf cfg.enable { }:
with lib; let
# Enable native Docker support cfg = config.custom.wsl;
virtualisation.docker.enable = true; in {
options.custom.wsl.enable = mkEnableOption "Enable WSL2 settings";
wsl = {
enable = true; config = mkIf cfg.enable {
wslConf.automount.root = "/mnt"; # Enable native Docker support
defaultUser = "sstent"; virtualisation.docker.enable = true;
startMenuLaunchers = true;
wslConf.interop.appendWindowsPath = false; wsl = {
#No longer needed in 23.05 enable = true;
#interop.preserveArgvZero = true; wslConf.automount.root = "/mnt";
#docker-native.enable = true; defaultUser = "sstent";
startMenuLaunchers = true;
nativeSystemd = true; wslConf.interop.appendWindowsPath = false;
# Enable integration with Docker Desktop (needs to be installed) #No longer needed in 23.05
# docker-desktop.enable = true; #interop.preserveArgvZero = true;
}; #docker-native.enable = true;
systemd.services.nixs-wsl-systemd-fix = { nativeSystemd = true;
description = "Fix the /dev/shm symlink to be a mount"; # Enable integration with Docker Desktop (needs to be installed)
unitConfig = { # docker-desktop.enable = true;
DefaultDependencies = "no"; };
Before = [
"sysinit.target" systemd.services.nixs-wsl-systemd-fix = {
"systemd-tmpfiles-setup-dev.service" description = "Fix the /dev/shm symlink to be a mount";
"systemd-tmpfiles-setup.service" unitConfig = {
"systemd-sysctl.service" DefaultDependencies = "no";
]; Before = [
ConditionPathExists = "/dev/shm"; "sysinit.target"
ConditionPathIsSymbolicLink = "/dev/shm"; "systemd-tmpfiles-setup-dev.service"
ConditionPathIsMountPoint = "/run/shm"; "systemd-tmpfiles-setup.service"
}; "systemd-sysctl.service"
serviceConfig = { ];
Type = "oneshot"; ConditionPathExists = "/dev/shm";
ExecStart = [ ConditionPathIsSymbolicLink = "/dev/shm";
"${pkgs.coreutils-full}/bin/rm /dev/shm" ConditionPathIsMountPoint = "/run/shm";
"/run/wrappers/bin/mount --bind -o X-mount.mkdir /run/shm /dev/shm" };
]; serviceConfig = {
}; Type = "oneshot";
wantedBy = [ "sysinit.target" ]; ExecStart = [
}; "${pkgs.coreutils-full}/bin/rm /dev/shm"
"/run/wrappers/bin/mount --bind -o X-mount.mkdir /run/shm /dev/shm"
];
};
wantedBy = ["sysinit.target"];
}; };
} };
}

View File

@@ -1,8 +1,9 @@
# A nixpkgs instance that is grabbed from the pinned nixpkgs commit in the lock file # A nixpkgs instance that is grabbed from the pinned nixpkgs commit in the lock file
# This is useful to avoid using channels when using legacy nix commands # This is useful to avoid using channels when using legacy nix commands
let lock = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked; let
lock = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked;
in in
import (fetchTarball { import (fetchTarball {
url = "https://github.com/nixos/nixpkgs/archive/${lock.rev}.tar.gz"; url = "https://github.com/nixos/nixpkgs/archive/${lock.rev}.tar.gz";
sha256 = lock.narHash; sha256 = lock.narHash;
}) })

View File

@@ -1,8 +1,7 @@
# This file defines overlays # This file defines overlays
{ inputs, ... }: {inputs, ...}: {
{
# This one brings our custom packages from the 'pkgs' directory # This one brings our custom packages from the 'pkgs' directory
additions = final: _prev: import ../pkgs { pkgs = final; }; additions = final: _prev: import ../pkgs {pkgs = final;};
# This one contains whatever you want to overlay # This one contains whatever you want to overlay
# You can change versions, add patches, set compilation flags, anything really. # You can change versions, add patches, set compilation flags, anything really.

View File

@@ -1,8 +1,6 @@
# Custom packages, that can be defined similarly to ones from nixpkgs # Custom packages, that can be defined similarly to ones from nixpkgs
# You can build them using 'nix build .#example' or (legacy) 'nix-build -A example' # You can build them using 'nix build .#example' or (legacy) 'nix-build -A example'
{pkgs ? (import ../nixpkgs.nix) {}}: {
{ pkgs ? (import ../nixpkgs.nix) { } }: {
# example = pkgs.callPackage ./example { }; # example = pkgs.callPackage ./example { };
npiperelay = pkgs.callPackage ./npiperelay { }; npiperelay = pkgs.callPackage ./npiperelay {};
} }

View File

@@ -1,11 +1,13 @@
{ lib, stdenv, fetchurl ,unzip }: {
lib,
let stdenv,
fetchurl,
unzip,
}: let
version = "1.6.3"; version = "1.6.3";
srcs = { srcs = {
x86_64-linux = fetchurl { x86_64-linux = fetchurl {
url = url = "https://github.com/jstarks/npiperelay/releases/download/v0.1.0/npiperelay_windows_amd64.zip";
"https://github.com/jstarks/npiperelay/releases/download/v0.1.0/npiperelay_windows_amd64.zip";
sha256 = "sha256-a572H/0XwDUHqaPVTYFdzrPa5mmsZ/w79CJdHnZM5fY="; sha256 = "sha256-a572H/0XwDUHqaPVTYFdzrPa5mmsZ/w79CJdHnZM5fY=";
}; };
@@ -15,38 +17,36 @@ let
# sha256 = "sha256-zuy4e9bzcRqDeXP6mfzZLCDK/3we25LH6xktnO6HXps="; # sha256 = "sha256-zuy4e9bzcRqDeXP6mfzZLCDK/3we25LH6xktnO6HXps=";
# }; # };
}; };
in
stdenv.mkDerivation rec {
pname = "npiperelay";
inherit version;
in stdenv.mkDerivation rec { src = srcs.${stdenv.hostPlatform.system};
pname = "npiperelay";
inherit version;
src = srcs.${stdenv.hostPlatform.system}; nativeBuildInputs = [unzip];
nativeBuildInputs = [ unzip ]; #buildInputs = [ qtserialport qtwebsockets ];
unpackPhase = ''
mkdir npiperelay-$version
cd npiperelay-$version
unzip $src
'';
#unpackPhase = "dpkg-deb -x $src .";
#buildInputs = [ qtserialport qtwebsockets ]; installPhase = ''
unpackPhase = '' mkdir -p $out/bin
mkdir npiperelay-$version cp npiperelay.exe $out/bin/npiperelay.exe
cd npiperelay-$version chmod +x $out/bin/npiperelay.exe
unzip $src '';
'';
#unpackPhase = "dpkg-deb -x $src .";
installPhase = '' meta = with lib; {
mkdir -p $out/bin description = "Helper to interface with Windows ssh-agent.exe service from Windows Subsystem for Linux (WSL)";
cp npiperelay.exe $out/bin/npiperelay.exe # 2019-08-19: The homepage links to old software that doesn't even work --
chmod +x $out/bin/npiperelay.exe # it fails to detect ConBee2.
''; homepage = "https://github.com/rupor-github/wsl-ssh-agent";
license = licenses.free;
meta = with lib; { platforms = ["x86_64-linux"];
description = maintainers = with maintainers; [sstent];
"Helper to interface with Windows ssh-agent.exe service from Windows Subsystem for Linux (WSL)"; };
# 2019-08-19: The homepage links to old software that doesn't even work -- }
# it fails to detect ConBee2.
homepage =
"https://github.com/rupor-github/wsl-ssh-agent";
license = licenses.free;
platforms = [ "x86_64-linux" ];
maintainers = with maintainers; [ sstent ];
};
}

View File

@@ -1,23 +1,23 @@
{ pkgs ? import <nixpkgs> {} }: {pkgs ? import <nixpkgs> {}}:
with pkgs; let
with pkgs; nixBin = writeShellScriptBin "nix" ''
let nixBin = ${nixFlakes}/bin/nix --option experimental-features "nix-command flakes" "$@"
writeShellScriptBin "nix" ''
${nixFlakes}/bin/nix --option experimental-features "nix-command flakes" "$@"
'';
in mkShell {
buildInputs = [
nix home-manager git ssh-to-age sops age
];
shellHook = ''
export FLAKE="$(pwd)"
export PATH="$FLAKE/bin:${nixBin}/bin:$PATH"
''; '';
} in
mkShell {
buildInputs = [
nix
home-manager
git
ssh-to-age
sops
age
];
shellHook = ''
export FLAKE="$(pwd)"
export PATH="$FLAKE/bin:${nixBin}/bin:$PATH"
'';
}
# { pkgs ? (import ./nixpkgs.nix) { } }: { # { pkgs ? (import ./nixpkgs.nix) { } }: {
# default = pkgs.mkShell { # default = pkgs.mkShell {
# # Enable experimental features without having to specify the argument # # Enable experimental features without having to specify the argument
@@ -25,3 +25,4 @@ in mkShell {
# nativeBuildInputs = with pkgs; [ nix home-manager git ssh-to-age sops age ]; # nativeBuildInputs = with pkgs; [ nix home-manager git ssh-to-age sops age ];
# }; # };
# } # }