Update various configurations

Flake outputs, hosts, users, and formatting of Nix files. et cetera, et
cetera.
This commit is contained in:
Gabriel Arazas 2021-12-11 13:37:27 +08:00
parent 2ccaca429a
commit adf04a9393
8 changed files with 88 additions and 120 deletions

View File

@ -3,9 +3,11 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
# Managing home configurations.
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
# Managing your secrets.
agenix.url = "github:ryantm/agenix";
agenix.inputs.nixpkgs.follows = "nixpkgs";
@ -82,6 +84,9 @@
# Stallman-senpai will be disappointed. :(
nixpkgs.config.allowUnfree = true;
# Let home-manager to manage itself.
programs.home-manager.enable = true;
};
in {
# Exposes only my library with the custom functions to make it easier to include in other flakes.

View File

@ -5,7 +5,8 @@
{ config, pkgs, ... }:
{
imports = [ # Include the results of the hardware scan.
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
];
@ -18,6 +19,7 @@
audio.enable = true;
fonts.enable = true;
hardware.enable = true;
cleanup.enable = true;
};
dev = {
enable = true;
@ -27,6 +29,7 @@
editors.neovim.enable = true;
themes.a-happy-gnome.enable = true;
users.users = [ "foo-dogsquared" ];
hardware-setup.backup-archive.enable = true;
};
# Use the systemd-boot EFI boot loader.
@ -71,61 +74,5 @@
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "21.11"; # Did you read the comment?
# This is my external hard disk so it has to be non-blocking.
fileSystems."/mnt/external-storage" = {
device = "/dev/disk/by-uuid/665A391C5A38EB07";
fsType = "ntfs";
noCheck = true;
options = [
"nofail"
"noauto"
"user"
# See systemd.mount.5 and systemd.automount.5 manual page for more
# details.
"x-systemd.automount"
"x-systemd.device-timeout=2"
"x-systemd.idle-timeout=2"
];
};
# Automated backup for my external storage.
services.borgbackup.jobs = {
personal_archive = {
exclude = [
"/home/*/.cache"
# The usual NodeJS shenanigans.
"*/node_modules"
"*/.next"
# Rust-related files.
"projects/software/*/result"
"projects/software/*/build"
"projects/software/*/target"
];
doInit = false;
removableDevice = true;
repo = "/mnt/external-storage/backups";
paths = [ "~/dotfiles" "~/library" "~/writings" ];
encryption = {
mode = "repokey";
passCommand = "${pkgs.gopass}/bin/gopass show misc/BorgBackup_pass";
};
compression = "auto,lzma";
startAt = "daily";
prune = {
prefix = "{hostname}-";
keep = {
within = "1d";
daily = 30;
weekly = 4;
monthly = 6;
yearly = 4;
};
};
};
};
}

View File

@ -4,22 +4,21 @@
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
boot.initrd.availableKernelModules =
[ "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/f52c2729-2036-4bdf-8d54-21f929f3447b";
fileSystems."/" = {
device = "/dev/disk/by-uuid/f52c2729-2036-4bdf-8d54-21f929f3447b";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/AB3A-34BC";
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/AB3A-34BC";
fsType = "vfat";
};

View File

@ -66,16 +66,20 @@ in rec {
mkUser ./users/foo-dogsquared {}
=> { ... } # A home-manager configuration set.
*/
mkUser = file: attrs@{ username ? (builtins.baseNameOf file), system ? sys, extraModules ? [], ... }:
mkUser = file:
attrs@{ username ? (builtins.baseNameOf file), system ? sys
, extraModules ? [ ], ... }:
let
hmConfigFunctionArgs = builtins.attrNames (builtins.functionArgs inputs.home-manager.lib.homeManagerConfiguration);
hmModules = lib.map (path: import path) (lib.modulesToList (lib.filesToAttrRec ../modules/home-manager));
in
inputs.home-manager.lib.homeManagerConfiguration {
hmConfigFunctionArgs = builtins.attrNames (builtins.functionArgs
inputs.home-manager.lib.homeManagerConfiguration);
hmModules = lib.map (path: import path)
(lib.modulesToList (lib.filesToAttrRec ../modules/home-manager));
in inputs.home-manager.lib.homeManagerConfiguration {
inherit system username;
configuration = import file;
homeDirectory = "/home/${username}";
extraModules = hmModules ++ extraModules ++ [ (lib.filterAttrs (n: _: !lib.elem n hmConfigFunctionArgs) attrs) ];
extraModules = hmModules ++ extraModules
++ [ (lib.filterAttrs (n: _: !lib.elem n hmConfigFunctionArgs) attrs) ];
extraSpecialArgs = { inherit lib system; };
};
}

22
modules/README.adoc Normal file
View File

@ -0,0 +1,22 @@
= Modules
:toc:
This directory contains modules for different components such as link:https://nixos.org/manual/nixos/stable/index.html#sec-writing-modules[NixOS modules] and link:https://github.com/nix-community/home-manager/[home-manager modules].
== Importing the modules
Usually, you'll see no `default.nix` in place since it is imported through other means.
One of the most common way is through `filesToAttr` defined in link:../lib[my custom library].
For example, to easily get a list of imported custom NixOS modules, here's one way with the custom library.
[source, nix]
----
lib.map (path: import path) (lib.modulesToList (lib.filesToAttr ./modules/nixos))
----
Each modules may have to be imported differently.
Please see the respective documentation (i.e., `man:configuration.nix(5)`, `man:home-configuration.nix` ) for more details.

View File

@ -25,7 +25,7 @@ buildGoModule rec {
'';
meta = with lib; {
description = "HTTP DNS client for humans.";
description = "HTTP DNS client for humans";
homepage = "https://github.com/mr-karan/doggo";
license = licenses.mit;
};

View File

@ -22,7 +22,9 @@ stdenv.mkDerivation rec {
];
postInstall = ''
install -Dm644 $out/share/gnome-shell/extensions/${passthru.extensionUuid}/schemas/* -t "${glib.makeSchemaPath "$out" "${pname}-${version}"}"
install -Dm644 $out/share/gnome-shell/extensions/${passthru.extensionUuid}/schemas/* -t "${
glib.makeSchemaPath "$out" "${pname}-${version}"
}"
# TODO: Uncomment once custom gsettings works.
# Unfortunately custom gsettings seems to be not properly integrated with NixOS yet.

View File

@ -3,11 +3,12 @@
{
home.packages = with pkgs; [
brave
mpv
emacs
github-cli
ncmpcpp
]
# Doom Emacs dependencies.
++ (with pkgs; [
git
ripgrep
gnutls
emacs-all-the-icons-fonts
@ -46,24 +47,11 @@
enable = true;
musicDirectory = "$HOME/library/music";
};
services.mpdris2.enable = true;
programs.ncmpcpp = {
enable = true;
package = pkgs.ncmpcpp.override { visualizerSupport = true; };
# TODO: Add more vim-related keybindings.
bindings = [
{ key = "j"; command = "scroll_down"; }
{ key = "k"; command = "scroll_up"; }
{ key = "J"; command = [ "select_item" "scroll_down" ]; }
{ key = "K"; command = [ "select_item" "scroll_up" ]; }
];
};
# My custom modules.
modules = {
bleachbit.enable = true;
i18n.enable = true;
archiving.enable = true;
dev = {
enable = true;
shell.enable = true;
@ -73,5 +61,6 @@
graphics.enable = true;
audio.enable = true;
};
research.enable = true;
};
}