chore: inital pre-commit tidy

This commit is contained in:
truxnell 2024-03-18 08:04:32 +11:00
parent 837fdfed30
commit c807e69147
28 changed files with 360 additions and 304 deletions

View file

@ -17,12 +17,14 @@
url = "github:nix-community/nix-vscode-extensions"; url = "github:nix-community/nix-vscode-extensions";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
outputs = { self, nixpkgs, sops-nix, ... }@inputs: outputs = {
with inputs; self,
{ nixpkgs,
sops-nix,
...
} @ inputs:
with inputs; {
# Use nixpkgs-fmt for 'nix fmt' # Use nixpkgs-fmt for 'nix fmt'
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt; formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
@ -33,7 +35,6 @@
(x: { (x: {
name = x; name = x;
value = nixpkgs.lib.nixosSystem { value = nixpkgs.lib.nixosSystem {
# Make inputs and the flake itself accessible as module parameters. # Make inputs and the flake itself accessible as module parameters.
# Technically, adding the inputs is redundant as they can be also # Technically, adding the inputs is redundant as they can be also
# accessed with flake-self.inputs.X, but adding them individually # accessed with flake-self.inputs.X, but adding them individually

View file

@ -1,5 +1,8 @@
{ config, pkgs, ... }:
{ {
config,
pkgs,
...
}: {
imports = [ imports = [
<nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix> <nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix>
@ -15,12 +18,10 @@
pkgs.vim pkgs.vim
pkgs.git pkgs.git
pkgs.dnsutils pkgs.dnsutils
]; ];
systemd.services.sshd.wantedBy = pkgs.lib.mkForce ["multi-user.target"]; systemd.services.sshd.wantedBy = pkgs.lib.mkForce ["multi-user.target"];
users.users.root.openssh.authorizedKeys.keys = [ users.users.root.openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMZS9J1ydflZ4iJdJgO8+vnN8nNSlEwyn9tbWU9OcysW truxnell@home" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMZS9J1ydflZ4iJdJgO8+vnN8nNSlEwyn9tbWU9OcysW truxnell@home"
]; ];
} }

View file

@ -1,15 +1,15 @@
# Edit this configuration file to define what should be installed on # Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page, on # your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). # https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
{ config, lib, pkgs, ... }:
{ {
imports = config,
[ lib,
pkgs,
...
}: {
imports = [
# Host-specific # Host-specific
./hardware-configuration.nix ./hardware-configuration.nix
]; ];
boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;
@ -63,7 +63,6 @@
]; ];
}; };
# List packages installed in system profile. To search, run: # List packages installed in system profile. To search, run:
# $ nix search wget # $ nix search wget
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
@ -88,7 +87,6 @@
}; };
}; };
# Some programs need SUID wrappers, can be configured further or are # Some programs need SUID wrappers, can be configured further or are
# started in user sessions. # started in user sessions.
# programs.mtr.enable = true; # programs.mtr.enable = true;
@ -139,6 +137,4 @@
# #
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
system.stateVersion = "23.11"; # Did you read the comment? system.stateVersion = "23.11"; # Did you read the comment?
} }

View file

@ -1,12 +1,20 @@
{ inputs, outputs, config, sops-nix, ... }: { {
imports = [ inputs,
outputs,
config,
sops-nix,
...
}: {
imports =
[
# inputs.home-manager.nixosModules.home-manager # inputs.home-manager.nixosModules.home-manager
#inputs.sops-nix.nixosModules.sops #inputs.sops-nix.nixosModules.sops
./locale.nix ./locale.nix
./nix.nix ./nix.nix
./openssh.nix ./openssh.nix
./packages.nix ./packages.nix
] ++ (builtins.attrValues {}); ]
++ (builtins.attrValues {});
# home-manager.extraSpecialArgs = { inherit inputs outputs; }; TODO Home-manager # home-manager.extraSpecialArgs = { inherit inputs outputs; }; TODO Home-manager

View file

@ -1,5 +1,8 @@
{ inputs, lib, ... }:
{ {
inputs,
lib,
...
}: {
nix = { nix = {
settings = { settings = {
experimental-features = ["nix-command" "flakes"]; experimental-features = ["nix-command" "flakes"];

View file

@ -1,11 +1,12 @@
{ outputs, lib, config, ... }: {
outputs,
let lib,
config,
...
}: let
inherit (config.networking) hostName; inherit (config.networking) hostName;
hosts = outputs.nixosConfigurations; hosts = outputs.nixosConfigurations;
in {
in
{
services.openssh = { services.openssh = {
enable = true; enable = true;
settings = { settings = {

View file

@ -1,5 +1,9 @@
{ config, pkgs, lib, ... }:
{ {
config,
pkgs,
lib,
...
}: {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
bat bat
jq jq
@ -10,13 +14,14 @@
git git
dnsutils dnsutils
nvd nvd
gh
# TODO Move # TODO Move
nixpkgs-fmt
nil
gh
sops
]; ];
programs.direnv = {
# TODO move to home-manager
enable = true;
nix-direnv.enable = true;
};
programs.mtr.enable = true; programs.mtr.enable = true;
} }

View file

@ -1,15 +1,20 @@
{ pkgs, config, ... }:
let ifTheyExist = groups: builtins.filter (group: builtins.hasAttr group config.users.groups) groups;
in
{ {
pkgs,
config,
...
}: let
ifTheyExist = groups: builtins.filter (group: builtins.hasAttr group config.users.groups) groups;
in {
users.users.truxnell = { users.users.truxnell = {
isNormalUser = true; isNormalUser = true;
shell = pkgs.fish; shell = pkgs.fish;
# passwordFile = config.sops.secrets.taylor-password.path; # passwordFile = config.sops.secrets.taylor-password.path;
# initialHashedPassword = ""; # TODO add key # initialHashedPassword = ""; # TODO add key
extraGroups = [ extraGroups =
[
"wheel" "wheel"
] ++ ifTheyExist [ ]
++ ifTheyExist [
"network" "network"
"samba-users" "samba-users"
]; ];

View file

@ -1,4 +1,9 @@
{ inputs, outputs, config, ... }: { {
inputs,
outputs,
config,
...
}: {
# Time # Time
networking.timeServers = ["10.8.10.1"]; networking.timeServers = ["10.8.10.1"];
services.chrony = { services.chrony = {

View file

@ -1,5 +1,8 @@
{ config, lib, ... }: { {
config,
lib,
...
}: {
# Current nixpkgs cf-ddns only supports using a env file for the apitoken # Current nixpkgs cf-ddns only supports using a env file for the apitoken
# but not for domains, which makes them hard to find. # but not for domains, which makes them hard to find.
# To circumvent this, I put both in the 'apiTokenFile' var # To circumvent this, I put both in the 'apiTokenFile' var
@ -15,7 +18,6 @@
# Restart when secret changes # Restart when secret changes
config.sops.secrets."system/networking/cloudflare-dyndns/apiTokenFile".restartUnits = ["cloudflare-dyndns"]; config.sops.secrets."system/networking/cloudflare-dyndns/apiTokenFile".restartUnits = ["cloudflare-dyndns"];
# Cloudflare dynamic dns to keep my DNS records pointed at home # Cloudflare dynamic dns to keep my DNS records pointed at home
config.services.cloudflare-dyndns = { config.services.cloudflare-dyndns = {
enable = true; enable = true;
@ -24,9 +26,4 @@
apiTokenFile = config.sops.secrets."system/networking/cloudflare-dyndns/apiTokenFile".path; apiTokenFile = config.sops.secrets."system/networking/cloudflare-dyndns/apiTokenFile".path;
domains = []; domains = [];
}; };
} }

View file

@ -1,7 +1,11 @@
# Ref: https://nixos.wiki/wiki/Encrypted_DNS#dnscrypt-proxy2 # Ref: https://nixos.wiki/wiki/Encrypted_DNS#dnscrypt-proxy2
{
{ inputs, outputs, pkgs, config, ... }: { inputs,
outputs,
pkgs,
config,
...
}: {
# Disable resolvd to ensure it doesnt re-write /etc/resolv.conf # Disable resolvd to ensure it doesnt re-write /etc/resolv.conf
config.services.resolved.enable = false; config.services.resolved.enable = false;

View file

@ -1,16 +1,18 @@
{ config, pkgs, lib, ... }:
{ {
config,
pkgs,
lib,
...
}: {
# Enable vscode & addons # Enable vscode & addons
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
(vscode-with-extensions.override { (vscode-with-extensions.override {
vscode = vscodium; vscode = vscodium;
vscodeExtensions = with vscode-extensions; [ vscodeExtensions = with vscode-extensions;
[
bbenoist.nix bbenoist.nix
]
] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [ ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
{ {
name = "prettier-vscode"; name = "prettier-vscode";
publisher = "esbenp"; publisher = "esbenp";
@ -53,8 +55,6 @@
sha256 = "0pww9qndd2vsizsibjsvscz9fbfx8srrj67x4vhmwr581q674944"; sha256 = "0pww9qndd2vsizsibjsvscz9fbfx8srrj67x4vhmwr581q674944";
} }
{ {
name = "todo-tree"; name = "todo-tree";
publisher = "gruntfuggly"; publisher = "gruntfuggly";
@ -131,7 +131,6 @@
version = "0.0.3"; version = "0.0.3";
sha256 = "1d1c18mr91ll5fsp0l0aszyi7nx0ad352ssm0fm40z81m4dmzm0w"; sha256 = "1d1c18mr91ll5fsp0l0aszyi7nx0ad352ssm0fm40z81m4dmzm0w";
} }
]; ];
}) })
]; ];

View file

@ -1,12 +1,7 @@
# Warning, this file is autogenerated by nix4vscode. Don't modify this manually. # Warning, this file is autogenerated by nix4vscode. Don't modify this manually.
{pkgs}: let
{ pkgs }:
let
vscode-utils = pkgs.vscode-utils; vscode-utils = pkgs.vscode-utils;
in in {
{
"ms-python"."python" = vscode-utils.extensionFromVscodeMarketplace { "ms-python"."python" = vscode-utils.extensionFromVscodeMarketplace {
name = "python"; name = "python";
publisher = "ms-python"; publisher = "ms-python";

View file

@ -1,8 +1,10 @@
{ config, pkgs, lib, ... }:
{ {
config,
pkgs,
lib,
...
}: {
programs.firefox = { programs.firefox = {
enable = true; enable = true;
}; };
} }

View file

@ -1,6 +1,9 @@
{ config, pkgs, lib, ... }:
{ {
config,
pkgs,
lib,
...
}: {
# Ref: https://nixos.wiki/wiki/GNOME # Ref: https://nixos.wiki/wiki/GNOME
# GNOME plz # GNOME plz
@ -15,16 +18,17 @@
layout = "us"; # `localctl` will give you layout = "us"; # `localctl` will give you
}; };
# And dconf # And dconf
programs.dconf.enable = true; programs.dconf.enable = true;
# dconf write /org/gnome/mutter/experimental-features "['scale-monitor-framebuffer']" # dconf write /org/gnome/mutter/experimental-features "['scale-monitor-framebuffer']"
# Exclude default GNOME packages that dont interest me. # Exclude default GNOME packages that dont interest me.
environment.gnome.excludePackages = (with pkgs; [ environment.gnome.excludePackages =
(with pkgs; [
gnome-photos gnome-photos
gnome-tour gnome-tour
]) ++ (with pkgs.gnome; [ ])
++ (with pkgs.gnome; [
cheese # webcam tool cheese # webcam tool
gnome-music gnome-music
gnome-terminal gnome-terminal
@ -39,5 +43,4 @@
hitori # sudoku game hitori # sudoku game
atomix # puzzle game atomix # puzzle game
]); ]);
} }

View file

@ -1,5 +1,9 @@
{ inputs, outputs, config, ... }: { {
inputs,
outputs,
config,
...
}: {
# init secret # init secret
config.sops.secrets."system/mail/maddy/envFile" = { config.sops.secrets."system/mail/maddy/envFile" = {
sopsFile = ./maddy.sops.yaml; sopsFile = ./maddy.sops.yaml;
@ -10,13 +14,10 @@
# Restart dnscrypt when secret changes # Restart dnscrypt when secret changes
config.sops.secrets."system/mail/maddy/envFile".restartUnits = ["maddy"]; config.sops.secrets."system/mail/maddy/envFile".restartUnits = ["maddy"];
# #
config.services.maddy = { config.services.maddy = {
enable = true; enable = true;
secrets = [config.sops.secrets."system/mail/maddy/envFile".path]; secrets = [config.sops.secrets."system/mail/maddy/envFile".path];
config = builtins.readFile ./maddy.conf; config = builtins.readFile ./maddy.conf;
}; };
} }

View file

@ -1,6 +1,9 @@
{ config, pkgs, lib, ... }:
{ {
config,
pkgs,
lib,
...
}: {
services.prometheus.exporters = { services.prometheus.exporters = {
node = { node = {
enable = true; enable = true;
@ -25,5 +28,4 @@
config.services.prometheus.exporters.node.port config.services.prometheus.exporters.node.port
config.services.prometheus.exporters.smartctl.port config.services.prometheus.exporters.smartctl.port
]; ];
} }

View file

@ -1,7 +1,11 @@
{ inputs, outputs, config, ... }: { {
inputs,
outputs,
config,
...
}: {
# SOPS settings # SOPS settings
# https://github.com/Mic92/sops-nix # https://github.com/Mic92/sops-nix
sops.age.sshKeyPaths = ["/etc/ssh/ssh_host_ed25519_key"]; sops.age.sshKeyPaths = ["/etc/ssh/ssh_host_ed25519_key"];
} }

View file

@ -1,12 +1,13 @@
# Edit this configuration file to define what should be installed on # Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page, on # your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). # https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
{ config, lib, pkgs, ... }:
{ {
imports = config,
[ lib,
pkgs,
...
}: {
imports = [
# Host-specific # Host-specific
./hardware-configuration.nix ./hardware-configuration.nix
@ -23,8 +24,6 @@
../common/optional/sops-nix.nix ../common/optional/sops-nix.nix
../common/optional/cloudflare-dyndns.nix ../common/optional/cloudflare-dyndns.nix
../common/optional/maddy.nix ../common/optional/maddy.nix
]; ];
boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;
@ -51,9 +50,6 @@
# Enable the X11 windowing system. # Enable the X11 windowing system.
# services.xserver.enable = true; # services.xserver.enable = true;
# Configure keymap in X11 # Configure keymap in X11
# services.xserver.xkb.layout = "us"; # services.xserver.xkb.layout = "us";
# services.xserver.xkb.options = "eurosign:e,caps:escape"; # services.xserver.xkb.options = "eurosign:e,caps:escape";
@ -68,7 +64,6 @@
# Enable touchpad support (enabled default in most desktopManager). # Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true; # services.xserver.libinput.enable = true;
# Some programs need SUID wrappers, can be configured further or are # Some programs need SUID wrappers, can be configured further or are
# started in user sessions. # started in user sessions.
# programs.mtr.enable = true; # programs.mtr.enable = true;
@ -107,6 +102,4 @@
# #
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
system.stateVersion = "23.11"; # Did you read the comment? system.stateVersion = "23.11"; # Did you read the comment?
} }

View file

@ -1,9 +1,13 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ {
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = []; imports = [];
boot.initrd.availableKernelModules = ["ata_piix" "mptspi" "uhci_hcd" "ehci_pci" "sd_mod" "sr_mod"]; boot.initrd.availableKernelModules = ["ata_piix" "mptspi" "uhci_hcd" "ehci_pci" "sd_mod" "sr_mod"];
@ -11,20 +15,17 @@
boot.kernelModules = ["kvm-amd"]; boot.kernelModules = ["kvm-amd"];
boot.extraModulePackages = []; boot.extraModulePackages = [];
fileSystems."/" = fileSystems."/" = {
{
device = "/dev/disk/by-label/nixos"; device = "/dev/disk/by-label/nixos";
fsType = "ext4"; fsType = "ext4";
}; };
fileSystems."/boot" = fileSystems."/boot" = {
{
device = "/dev/disk/by-label/boot"; device = "/dev/disk/by-label/boot";
fsType = "vfat"; fsType = "vfat";
}; };
swapDevices = swapDevices = [{device = "/dev/sda2";}];
[{ device = "/dev/sda2"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's
@ -37,6 +38,4 @@
virtualisation.vmware.guest.enable = true; virtualisation.vmware.guest.enable = true;
virtualisation.virtualbox.guest.enable = true; virtualisation.virtualbox.guest.enable = true;
virtualisation.virtualbox.guest.x11 = true; virtualisation.virtualbox.guest.x11 = true;
} }

View file

@ -1,6 +1,8 @@
{ config, lib, ... }:
{ {
config,
lib,
...
}: {
imports = [./playground.nix]; imports = [./playground.nix];
boot.isContainer = true; boot.isContainer = true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";

View file

@ -1,3 +1,8 @@
{ config, pkgs, lib, inputs, outputs, ... }: {
config,
{ } pkgs,
lib,
inputs,
outputs,
...
}: {}

View file

@ -1,5 +1,4 @@
{ inputs, ... }: {inputs, ...}: {
{
unstable-packages = final: _prev: { unstable-packages = final: _prev: {
unstable = import inputs.nixpkgs-unstable { unstable = import inputs.nixpkgs-unstable {
system = final.system; system = final.system;

26
shell.nix Normal file
View file

@ -0,0 +1,26 @@
# Shell for bootstrapping flake-enabled nix and other tooling
{
pkgs ?
# If pkgs is not defined, instanciate nixpkgs from locked commit
let
lock =
(builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked;
nixpkgs = fetchTarball {
url = "https://github.com/nixos/nixpkgs/archive/${lock.rev}.tar.gz";
sha256 = lock.narHash;
};
in
import nixpkgs {overlays = [];},
...
}:
pkgs.mkShell {
NIX_CONFIG = "extra-experimental-features = nix-command flakes repl-flake";
nativeBuildInputs = with pkgs; [
nixpkgs-fmt
nil
sops
pre-commit
go-task
alejandra
];
}