chore: run formatter

This commit is contained in:
2025-09-27 22:27:55 +05:00
parent 23ddc84bfc
commit 307b866cc6
44 changed files with 230 additions and 228 deletions

View File

@@ -10,14 +10,17 @@
}; };
}; };
outputs = { self, nixpkgs, flake-utils, fenix }: outputs = {
flake-utils.lib.eachDefaultSystem (system: self,
let nixpkgs,
flake-utils,
fenix,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
fenixLib = fenix.packages.${system}; fenixLib = fenix.packages.${system};
rustToolchain = fenixLib.stable.toolchain; rustToolchain = fenixLib.stable.toolchain;
in in {
{
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
lua-language-server lua-language-server

View File

@@ -40,8 +40,7 @@
}; };
}; };
outputs = { nixpkgs, ... }@inputs: outputs = {nixpkgs, ...} @ inputs: let
let
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
mkHost = host: { mkHost = host: {
${host} = nixpkgs.lib.nixosSystem { ${host} = nixpkgs.lib.nixosSystem {
@@ -50,15 +49,15 @@
# Extend lib with lib.custom # Extend lib with lib.custom
lib = nixpkgs.lib.extend (self: super: { lib = nixpkgs.lib.extend (self: super: {
custom = import ./lib { inherit (nixpkgs) lib; }; custom = import ./lib {inherit (nixpkgs) lib;};
}); });
}; };
modules = [ ./hosts/nixos/${host} ]; modules = [./hosts/nixos/${host}];
}; };
}; };
mkHostConfigs = hosts: mkHostConfigs = hosts:
lib.foldl (acc: set: acc // set) { } lib.foldl (acc: set: acc // set) {}
(lib.map (host: mkHost host) hosts); (lib.map (host: mkHost host) hosts);
readHosts = folder: lib.attrNames (builtins.readDir ./hosts/${folder}); readHosts = folder: lib.attrNames (builtins.readDir ./hosts/${folder});
in { in {
@@ -66,8 +65,9 @@
devShell.x86_64-linux = let devShell.x86_64-linux = let
pkgs = nixpkgs.legacyPackages.x86_64-linux; pkgs = nixpkgs.legacyPackages.x86_64-linux;
in pkgs.mkShell { in
buildInputs = with pkgs; [ nil lua-language-server ]; pkgs.mkShell {
buildInputs = with pkgs; [nil lua-language-server];
}; };
}; };
} }

View File

@@ -1,6 +1,12 @@
{ config, lib, pkgs, hostSpec, ... }: { {
config,
lib,
pkgs,
hostSpec,
...
}: {
imports = lib.flatten [ imports = lib.flatten [
(map lib.custom.relativeToRoot [ "modules/common" "modules/home-manager" ]) (map lib.custom.relativeToRoot ["modules/common" "modules/home-manager"])
./kitty.nix ./kitty.nix
./direnv.nix ./direnv.nix
@@ -14,7 +20,7 @@
username = lib.mkDefault config.hostSpec.username; username = lib.mkDefault config.hostSpec.username;
homeDirectory = lib.mkDefault config.hostSpec.home; homeDirectory = lib.mkDefault config.hostSpec.home;
stateVersion = lib.mkDefault "25.05"; stateVersion = lib.mkDefault "25.05";
sessionPath = [ "$HOME/.local/bin" ]; sessionPath = ["$HOME/.local/bin"];
sessionVariables = { sessionVariables = {
FLAKE = "$HOME/src/nix/nix-config"; FLAKE = "$HOME/src/nix/nix-config";
SHELL = "zsh"; SHELL = "zsh";
@@ -52,7 +58,7 @@
nix = { nix = {
package = lib.mkDefault pkgs.nix; package = lib.mkDefault pkgs.nix;
settings = { settings = {
experimental-features = [ "nix-command" "flakes" ]; experimental-features = ["nix-command" "flakes"];
warn-dirty = false; warn-dirty = false;
}; };
}; };

View File

@@ -1,4 +1,4 @@
{ pkgs, ... }: { {pkgs, ...}: {
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;
home.packages = with pkgs; [ nerd-fonts.jetbrains-mono ]; home.packages = with pkgs; [nerd-fonts.jetbrains-mono];
} }

View File

@@ -1,9 +1,4 @@
{ {config, ...}: {
config,
...
}:
{
programs.ghostty = { programs.ghostty = {
enable = true; enable = true;

View File

@@ -1,4 +1,9 @@
{ lib, pkgs, config, ... }: { {
lib,
pkgs,
config,
...
}: {
programs.git = { programs.git = {
package = pkgs.gitAndTools.gitFull; package = pkgs.gitAndTools.gitFull;
enable = true; enable = true;
@@ -7,15 +12,15 @@
lfs.enable = true; lfs.enable = true;
extraConfig = { extraConfig = {
gpg = { format = "ssh"; }; gpg = {format = "ssh";};
"gpg \"ssh\"" = { "gpg \"ssh\"" = {
program = "${lib.getExe' pkgs._1password-gui "op-ssh-sign"}"; program = "${lib.getExe' pkgs._1password-gui "op-ssh-sign"}";
}; };
commit = { gpgsign = true; }; commit = {gpgsign = true;};
user = { signingKey = "~/.ssh/id_rihla.pub"; }; user = {signingKey = "~/.ssh/id_rihla.pub";};
pull = { rebase = true; }; pull = {rebase = true;};
init = { defaultBranch = "main"; }; init = {defaultBranch = "main";};
lfs = { locksverify = true; }; lfs = {locksverify = true;};
}; };
}; };
} }

View File

@@ -1,9 +1,4 @@
{ {config, ...}: {
config,
...
}:
{
programs.kitty = { programs.kitty = {
enable = true; enable = true;

View File

@@ -1,5 +1,3 @@
{ ... }: {...}: {
programs.btop = {enable = true;};
{
programs.btop = { enable = true; };
} }

View File

@@ -1,4 +1,4 @@
{ pkgs, ... }: { {pkgs, ...}: {
programs.firefox = { programs.firefox = {
enable = true; enable = true;
package = pkgs.firefox.override { package = pkgs.firefox.override {

View File

@@ -1,6 +1,4 @@
{ pkgs, ... }: {pkgs, ...}: {
{
home.packages = with pkgs; [ home.packages = with pkgs; [
lazygit lazygit
gh gh

View File

@@ -1,6 +1,4 @@
{ config, ... }: {config, ...}: {
{
programs.neovim = { programs.neovim = {
enable = true; enable = true;
defaultEditor = true; defaultEditor = true;
@@ -9,6 +7,7 @@
}; };
# Create a symlink from ~/.config/nvim to the dotfiles directory # Create a symlink from ~/.config/nvim to the dotfiles directory
home.file.".config/nvim".source = config.lib.file.mkOutOfStoreSymlink home.file.".config/nvim".source =
config.lib.file.mkOutOfStoreSymlink
"${config.home.homeDirectory}/git/nix-config/dotfiles/nvim"; "${config.home.homeDirectory}/git/nix-config/dotfiles/nvim";
} }

View File

@@ -1,5 +1,5 @@
{ ... }: {...}: let
let onePassPath = "~/.1password/agent.sock"; onePassPath = "~/.1password/agent.sock";
in { in {
programs.ssh = { programs.ssh = {
enable = true; enable = true;

View File

@@ -1 +1 @@
{ ... }: { programs.starship.enable = true; } {...}: {programs.starship.enable = true;}

View File

@@ -1,12 +1,15 @@
{ config, lib, pkgs, ... }:
{ {
config,
lib,
pkgs,
...
}: {
home = { home = {
file = { file = {
"${config.xdg.configHome}/tmux".source = "${config.xdg.configHome}/tmux".source =
lib.custom.relativeToRoot "dotfiles/tmux"; lib.custom.relativeToRoot "dotfiles/tmux";
}; };
packages = with pkgs; [ tmux ]; packages = with pkgs; [tmux];
}; };
} }

View File

@@ -1,4 +1,4 @@
{ config, ... }: { {config, ...}: {
programs.zsh = { programs.zsh = {
enable = true; enable = true;
enableCompletion = true; enableCompletion = true;

View File

@@ -1,4 +1,4 @@
{ lib, ... }: { {lib, ...}: {
imports = lib.flatten [ imports = lib.flatten [
# #
# ========== Required Configs ========== # ========== Required Configs ==========

View File

@@ -1,6 +1,4 @@
{ pkgs, ... }: {pkgs, ...}: {
{
home.packages = with pkgs; [ home.packages = with pkgs; [
discord discord
protonmail-desktop protonmail-desktop

View File

@@ -1,6 +1,10 @@
{ pkgs, inputs, config, lib, ... }:
{ {
pkgs,
inputs,
config,
lib,
...
}: {
imports = lib.flatten [ imports = lib.flatten [
inputs.home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager
inputs.sops-nix.nixosModules.sops inputs.sops-nix.nixosModules.sops
@@ -14,7 +18,7 @@
hostSpec = { hostSpec = {
username = "shahab"; username = "shahab";
handle = "shahab96"; handle = "shahab96";
email = { user = "shahab@dogar.dev"; }; email = {user = "shahab@dogar.dev";};
userFullName = "Shahab Dogar"; userFullName = "Shahab Dogar";
domain = "rihla"; domain = "rihla";
networking.ports.tcp.ssh = 22; networking.ports.tcp.ssh = 22;
@@ -50,13 +54,13 @@
auto-optimise-store = true; auto-optimise-store = true;
warn-dirty = false; warn-dirty = false;
trusted-users = [ "@wheel" ]; trusted-users = ["@wheel"];
substituters = [ "https://hyprland.cachix.org" ]; substituters = ["https://hyprland.cachix.org"];
trusted-public-keys = [ trusted-public-keys = [
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
]; ];
experimental-features = [ "nix-command" "flakes" ]; experimental-features = ["nix-command" "flakes"];
}; };
}; };
@@ -70,7 +74,7 @@
}; };
# ========= Sops ========= # ========= Sops =========
environment.systemPackages = with pkgs; [ sops ]; environment.systemPackages = with pkgs; [sops];
# #
# ========== Localization ========== # ========== Localization ==========

View File

@@ -1,6 +1,12 @@
{ lib, config, device, withSwap, swapSize, label, ... }:
{ {
lib,
config,
device,
withSwap,
swapSize,
label,
...
}: {
disko = { disko = {
devices = { devices = {
disk = { disk = {
@@ -34,8 +40,7 @@
passwordFile = "/tmp/secret.key"; passwordFile = "/tmp/secret.key";
settings = { settings = {
allowDiscards = true; allowDiscards = true;
crypttabExtraOpts = crypttabExtraOpts = ["fido2-device=auto" "token-timeout=10"];
[ "fido2-device=auto" "token-timeout=10" ];
}; };
content = { content = {
type = "lvm_pv"; type = "lvm_pv";
@@ -62,20 +67,19 @@
size = "100%"; size = "100%";
content = { content = {
type = "btrfs"; type = "btrfs";
extraArgs = [ "-L" label "-f" ]; extraArgs = ["-L" label "-f"];
subvolumes = { subvolumes = {
"@root" = { "@root" = {
mountpoint = "/"; mountpoint = "/";
mountOptions = [ "subvol=root" "compress=zstd" "noatime" ]; mountOptions = ["subvol=root" "compress=zstd" "noatime"];
}; };
"@persist" = { "@persist" = {
mountpoint = config.hostSpec.persist; mountpoint = config.hostSpec.persist;
mountOptions = mountOptions = ["subvol=persist" "compress=zstd" "noatime"];
[ "subvol=persist" "compress=zstd" "noatime" ];
}; };
"@nix" = { "@nix" = {
mountpoint = "/nix"; mountpoint = "/nix";
mountOptions = [ "subvol=nix" "compress=zstd" "noatime" ]; mountOptions = ["subvol=nix" "compress=zstd" "noatime"];
}; };
}; };
}; };

View File

@@ -1,11 +1,9 @@
{ config, ... }: {config, ...}: {
{
programs = { programs = {
_1password.enable = true; _1password.enable = true;
_1password-gui = { _1password-gui = {
enable = true; enable = true;
polkitPolicyOwners = [ config.hostSpec.username ]; polkitPolicyOwners = [config.hostSpec.username];
}; };
}; };
} }

View File

@@ -1,5 +1,3 @@
{ pkgs, ... }: {pkgs, ...}: {
environment.systemPackages = with pkgs; [claude-code];
{
environment.systemPackages = with pkgs; [ claude-code ];
} }

View File

@@ -1,5 +1,3 @@
{ ... }: {...}: {
{
programs.dconf.enable = true; programs.dconf.enable = true;
} }

View File

@@ -1,4 +1,4 @@
{ pkgs, ... }: { {pkgs, ...}: {
virtualisation = { virtualisation = {
podman = { podman = {
enable = true; enable = true;
@@ -11,7 +11,7 @@
}; };
}; };
containers = { registries = { search = [ "docker.io" ]; }; }; containers = {registries = {search = ["docker.io"];};};
libvirtd = { libvirtd = {
enable = true; enable = true;
@@ -20,7 +20,7 @@
ovmf = { ovmf = {
enable = true; enable = true;
packages = with pkgs; [ OVMFFull.fd ]; packages = with pkgs; [OVMFFull.fd];
}; };
}; };
}; };

View File

@@ -1,5 +1,3 @@
{ pkgs, ... }: {pkgs, ...}: {
environment.systemPackages = with pkgs; [hoppscotch];
{
environment.systemPackages = with pkgs; [ hoppscotch ];
} }

View File

@@ -1,6 +1,8 @@
{ inputs, pkgs, ... }:
{ {
inputs,
pkgs,
...
}: {
programs.hyprland = { programs.hyprland = {
enable = true; enable = true;
package = package =

View File

@@ -1,5 +1,3 @@
{ ... }: {...}: {
{
programs.nix-ld.enable = true; programs.nix-ld.enable = true;
} }

View File

@@ -1,5 +1,3 @@
{ pkgs, ... }: {pkgs, ...}: {
environment.systemPackages = with pkgs; [sbctl];
{
environment.systemPackages = with pkgs; [ sbctl ];
} }

View File

@@ -1,6 +1,4 @@
{ pkgs, ... }: {pkgs, ...}: {
{
services = { services = {
# Enable sound with pipewire. # Enable sound with pipewire.
pulseaudio.enable = false; pulseaudio.enable = false;
@@ -15,5 +13,5 @@
security.rtkit.enable = true; security.rtkit.enable = true;
environment.systemPackages = environment.systemPackages =
builtins.attrValues { inherit (pkgs) pavucontrol; }; builtins.attrValues {inherit (pkgs) pavucontrol;};
} }

View File

@@ -1,6 +1,4 @@
{ ... }: {...}: {
{
services.blueman.enable = true; services.blueman.enable = true;
hardware = { hardware = {
bluetooth.enable = true; bluetooth.enable = true;

View File

@@ -1,5 +1,3 @@
{ ... }: {...}: {
{
services.fwupd.enable = true; services.fwupd.enable = true;
} }

View File

@@ -1,12 +1,9 @@
{ pkgs, ... }: {pkgs, ...}: {
{
services.greetd = { services.greetd = {
enable = true; enable = true;
settings = { settings = {
default_session = { default_session = {
command = command = "${pkgs.tuigreet}/bin/tuigreet --greeting 'Welcome to NixOS!' --asterisks --remember --remember-user-session --time --cmd ${pkgs.hyprland}/bin/Hyprland";
"${pkgs.tuigreet}/bin/tuigreet --greeting 'Welcome to NixOS!' --asterisks --remember --remember-user-session --time --cmd ${pkgs.hyprland}/bin/Hyprland";
user = "greeter"; user = "greeter";
}; };
}; };

View File

@@ -1,9 +1,9 @@
{ config, ... }: {config, ...}: let
let sshPort = config.hostSpec.networking.ports.tcp.ssh; sshPort = config.hostSpec.networking.ports.tcp.ssh;
in { in {
services.openssh = { services.openssh = {
enable = true; enable = true;
ports = [ sshPort ]; ports = [sshPort];
settings = { settings = {
PermitRootLogin = "no"; PermitRootLogin = "no";
@@ -14,5 +14,5 @@ in {
openFirewall = true; openFirewall = true;
}; };
networking.firewall.allowedTCPPorts = [ sshPort ]; networking.firewall.allowedTCPPorts = [sshPort];
} }

View File

@@ -1,6 +1,4 @@
# Reminder that CUPS cpanel defaults to localhost:631 # Reminder that CUPS cpanel defaults to localhost:631
{ ... }: {...}: {
{
services.printing.enable = true; services.printing.enable = true;
} }

View File

@@ -1,5 +1,3 @@
{ ... }: {...}: {
{
services.pcscd.enable = true; services.pcscd.enable = true;
} }

View File

@@ -1,6 +1,4 @@
{ pkgs, ... }: {pkgs, ...}: {
{
# yubikey login / sudo # yubikey login / sudo
security.pam = { security.pam = {
u2f = { u2f = {
@@ -13,5 +11,5 @@
}; };
}; };
environment.systemPackages = with pkgs; [ yubikey-manager ]; environment.systemPackages = with pkgs; [yubikey-manager];
} }

View File

@@ -1,5 +1,9 @@
{ pkgs, config, lib, ... }: {
let pkgs,
config,
lib,
...
}: let
hostSpec = config.hostSpec; hostSpec = config.hostSpec;
in { in {
specialisation.gaming.configuration = { specialisation.gaming.configuration = {
@@ -15,7 +19,7 @@ in {
}; };
home-manager.users."${hostSpec.username}".imports = lib.flatten [ home-manager.users."${hostSpec.username}".imports = lib.flatten [
({ config, ... }: ({config, ...}:
import (lib.custom.relativeToRoot import (lib.custom.relativeToRoot
"home/${hostSpec.username}/specialisations/gaming.nix") { "home/${hostSpec.username}/specialisations/gaming.nix") {
inherit pkgs; inherit pkgs;
@@ -24,6 +28,6 @@ in {
powerManagement.cpuFreqGovernor = "performance"; powerManagement.cpuFreqGovernor = "performance";
environment.systemPackages = with pkgs; [ mangohud protonup-qt ]; environment.systemPackages = with pkgs; [mangohud protonup-qt];
}; };
} }

View File

@@ -1,5 +1,10 @@
{ pkgs, config, lib, inputs, ... }: {
let pkgs,
config,
lib,
inputs,
...
}: let
hostSpec = config.hostSpec; hostSpec = config.hostSpec;
pubKeys = lib.filesystem.listFilesRecursive ./keys; pubKeys = lib.filesystem.listFilesRecursive ./keys;
in { in {
@@ -13,15 +18,14 @@ in {
shell = pkgs.zsh; shell = pkgs.zsh;
home = hostSpec.home; home = hostSpec.home;
isNormalUser = true; isNormalUser = true;
hashedPassword = hashedPassword = "$y$j9T$pvjyL7hL5x2VBarGNTnMl1$mLA2UsWTbfp8Hgp/ug5l8224thi..Mo8.p7ME.tDZ.4";
"$y$j9T$pvjyL7hL5x2VBarGNTnMl1$mLA2UsWTbfp8Hgp/ug5l8224thi..Mo8.p7ME.tDZ.4"; extraGroups = ["networkmanager" "wheel" "input" "libvirtd"];
extraGroups = [ "networkmanager" "wheel" "input" "libvirtd" ];
# Read all keys in ./keys and add them to authorizedKeys. # Read all keys in ./keys and add them to authorizedKeys.
openssh.authorizedKeys.keys = openssh.authorizedKeys.keys =
lib.lists.forEach pubKeys (key: builtins.readFile key); lib.lists.forEach pubKeys (key: builtins.readFile key);
packages = with pkgs; [ libnotify ]; packages = with pkgs; [libnotify];
}; };
}; };
@@ -31,7 +35,7 @@ in {
hostSpec = config.hostSpec; hostSpec = config.hostSpec;
}; };
users.${hostSpec.username}.imports = lib.flatten [ users.${hostSpec.username}.imports = lib.flatten [
({ config, ... }: ({config, ...}:
import (lib.custom.relativeToRoot import (lib.custom.relativeToRoot
"home/${hostSpec.username}/${hostSpec.hostName}.nix") { "home/${hostSpec.username}/${hostSpec.hostName}.nix") {
inherit pkgs inputs config lib hostSpec; inherit pkgs inputs config lib hostSpec;

View File

@@ -1,6 +1,10 @@
{ inputs, pkgs, lib, config, ... }:
{ {
inputs,
pkgs,
lib,
config,
...
}: {
imports = lib.flatten [ imports = lib.flatten [
# #
# ========= Hardware ========= # ========= Hardware =========
@@ -33,7 +37,7 @@
# #
# ========= Required Configs ========= # ========= Required Configs =========
# #
(map lib.custom.relativeToRoot [ "hosts/common/core" ]) (map lib.custom.relativeToRoot ["hosts/common/core"])
# #
# ========= Optional Configs ========= # ========= Optional Configs =========
@@ -99,7 +103,8 @@
efi.canTouchEfiVariables = true; efi.canTouchEfiVariables = true;
}; };
initrd.postResumeCommands = lib.mkIf config.hostSpec.impermanance initrd.postResumeCommands =
lib.mkIf config.hostSpec.impermanance
(lib.mkAfter '' (lib.mkAfter ''
mkdir /btrfs_tmp mkdir /btrfs_tmp
mount /dev/crypt_vg/root /btrfs_tmp mount /dev/crypt_vg/root /btrfs_tmp
@@ -133,7 +138,7 @@
security.rtkit.enable = true; security.rtkit.enable = true;
environment.systemPackages = with pkgs; [ pciutils bc ]; environment.systemPackages = with pkgs; [pciutils bc];
system.stateVersion = "25.05"; system.stateVersion = "25.05";
} }

View File

@@ -1,8 +1,14 @@
# 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.
{ pkgs, config, lib, modulesPath, ... }: { {
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; pkgs,
config,
lib,
modulesPath,
...
}: {
imports = [(modulesPath + "/installer/scan/not-detected.nix")];
boot = { boot = {
initrd = { initrd = {
@@ -15,11 +21,11 @@
"usb_storage" "usb_storage"
"sd_mod" "sd_mod"
]; ];
kernelModules = [ ]; kernelModules = [];
}; };
kernelModules = [ "kvm-amd" ]; kernelModules = ["kvm-amd"];
extraModulePackages = [ ]; extraModulePackages = [];
}; };
# 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
@@ -36,7 +42,7 @@
lib.mkDefault config.hardware.enableRedistributableFirmware; lib.mkDefault config.hardware.enableRedistributableFirmware;
graphics = { graphics = {
enable = true; enable = true;
extraPackages = with pkgs; [ amdvlk ]; extraPackages = with pkgs; [amdvlk];
}; };
}; };
} }

View File

@@ -1,5 +1,3 @@
{ lib, ... }: {lib, ...}: {
{
relativeToRoot = lib.path.append ../.; relativeToRoot = lib.path.append ../.;
} }

View File

@@ -1,5 +1,3 @@
{ ... }: {...}: {
imports = [./host-spec.nix];
{
imports = [ ./host-spec.nix ];
} }

View File

@@ -1,5 +1,9 @@
# Specifications For Differentiating Hosts # Specifications For Differentiating Hosts
{ config, lib, ... }: { {
config,
lib,
...
}: {
options.hostSpec = { options.hostSpec = {
username = lib.mkOption { username = lib.mkOption {
type = lib.types.str; type = lib.types.str;
@@ -14,7 +18,7 @@
description = "The email of the user"; description = "The email of the user";
}; };
networking = lib.mkOption { networking = lib.mkOption {
default = { }; default = {};
type = lib.types.attrsOf lib.types.anything; type = lib.types.attrsOf lib.types.anything;
description = "An attribute set of networking information"; description = "An attribute set of networking information";
}; };
@@ -68,8 +72,7 @@
scaling = lib.mkOption { scaling = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "1"; default = "1";
description = description = "Used to indicate what scaling to use. Floating point number";
"Used to indicate what scaling to use. Floating point number";
}; };
font = lib.mkOption { font = lib.mkOption {
type = lib.types.str; type = lib.types.str;

View File

@@ -1,5 +1,3 @@
{ ... }: {...}: {
imports = [./yubikey-touch-detector.nix];
{
imports = [ ./yubikey-touch-detector.nix ];
} }

View File

@@ -1,11 +1,15 @@
{ config, lib, pkgs, ... }: {
config,
with lib; lib,
pkgs,
let cfg = config.services.yubikey-touch-detector; ...
}:
with lib; let
cfg = config.services.yubikey-touch-detector;
in { in {
options.services.yubikey-touch-detector = { options.services.yubikey-touch-detector = {
enable = mkEnableOption enable =
mkEnableOption
"a tool to detect when your YubiKey is waiting for a touch"; "a tool to detect when your YubiKey is waiting for a touch";
package = mkOption { package = mkOption {
@@ -22,7 +26,7 @@ in {
extraArgs = mkOption { extraArgs = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = [ "--libnotify" ]; default = ["--libnotify"];
defaultText = literalExpression ''[ "--libnotify" ]''; defaultText = literalExpression ''[ "--libnotify" ]'';
description = '' description = ''
Extra arguments to pass to the tool. The arguments are not escaped. Extra arguments to pass to the tool. The arguments are not escaped.
@@ -31,20 +35,19 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = [ cfg.package ]; home.packages = [cfg.package];
# Service description licensed under ISC # Service description licensed under ISC
# See https://github.com/maximbaz/yubikey-touch-detector/blob/c9fdff7163361d6323e2de0449026710cacbc08a/LICENSE # See https://github.com/maximbaz/yubikey-touch-detector/blob/c9fdff7163361d6323e2de0449026710cacbc08a/LICENSE
# Author: Maxim Baz # Author: Maxim Baz
systemd.user.sockets.yubikey-touch-detector = mkIf cfg.socket.enable { systemd.user.sockets.yubikey-touch-detector = mkIf cfg.socket.enable {
Unit.Description = Unit.Description = "Unix socket activation for YubiKey touch detector service";
"Unix socket activation for YubiKey touch detector service";
Socket = { Socket = {
ListenFIFO = "%t/yubikey-touch-detector.sock"; ListenFIFO = "%t/yubikey-touch-detector.sock";
RemoveOnStop = true; RemoveOnStop = true;
SocketMode = "0660"; SocketMode = "0660";
}; };
Install.WantedBy = [ "sockets.target" ]; Install.WantedBy = ["sockets.target"];
}; };
# Same license thing for the description here # Same license thing for the description here
@@ -52,19 +55,19 @@ in {
Unit = { Unit = {
Description = "Detects when your YubiKey is waiting for a touch"; Description = "Detects when your YubiKey is waiting for a touch";
Requires = Requires =
optionals cfg.socket.enable [ "yubikey-touch-detector.socket" ]; optionals cfg.socket.enable ["yubikey-touch-detector.socket"];
}; };
Service = { Service = {
ExecStart = "${cfg.package}/bin/yubikey-touch-detector ${ ExecStart = "${cfg.package}/bin/yubikey-touch-detector ${
concatStringsSep " " cfg.extraArgs concatStringsSep " " cfg.extraArgs
}"; }";
Environment = [ "PATH=${lib.makeBinPath [ pkgs.gnupg ]}" ]; Environment = ["PATH=${lib.makeBinPath [pkgs.gnupg]}"];
Restart = "on-failure"; Restart = "on-failure";
RestartSec = "1sec"; RestartSec = "1sec";
}; };
Install.Also = Install.Also =
optionals cfg.socket.enable [ "yubikey-touch-detector.socket" ]; optionals cfg.socket.enable ["yubikey-touch-detector.socket"];
Install.WantedBy = [ "default.target" ]; Install.WantedBy = ["default.target"];
}; };
}; };
} }