Compare commits

..

No commits in common. "master" and "before-git" have entirely different histories.

585 changed files with 360 additions and 64022 deletions

View file

@ -1,19 +0,0 @@
name: Discord
on:
- workflow_dispatch
- push
jobs:
discord_commits:
runs-on: ubuntu-latest
name: discord commits
if: contains(github.event.head_commit.message, '(servers)')
steps:
- name: Discommit
uses: https://github.com/matt1432/discommit@v0.0.2
with:
discord_webhook: ${{ secrets.DISCORD_WEBHOOK }}
api_url: 'https://git.nelim.org/api/v1/repos/$OWNER/$REPO/git/commits/$REF'
title: 'New commit containing changes to server configs:'

5
.gitattributes vendored
View file

@ -1,5 +0,0 @@
flake.lock -diff
flake.nix -diff
**/non-declarative-conf -diff
**/package-lock.json -diff
**/HomeAssistantGenerated -diff

23
.gitignore vendored
View file

@ -1,23 +0,0 @@
# Python
*.egg-info
# NPM
*node_modules
*build/
# Direnv
*.direnv/
# Generated by nix
result*
!results/
.nixd.json
## AGS
**/vars.ts
**/config.js
*icons
**/types
# Other
*.temp

View file

@ -1,16 +0,0 @@
MIT No Attribution
Copyright 2024 Mathis H.
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

324
README.md
View file

@ -1,100 +1,236 @@
# My NixOS configs
## AGS
You might find it weird that most of my config is written in TypeScript.
That's because all my desktops run
[AGS](https://github.com/Aylur/ags)
for UI. Click on
[this](https://git.nelim.org/matt1432/nixos-configs/src/branch/master/modules/ags)
to see my configuration.
I'm also a victim of Stockholm syndrome at this point and make my scripts
in TypeScript because it's the scripting language I am most comfortable with.
## About
### General
This repo is the complete configuration of machines I own running NixOS or Nix
and any other related smaller projects exposed by a Nix Flake.
Its main directory structure is based on a flake's
[outputs](https://wiki.nixos.org/wiki/Flakes#Output_schema).
I try to follow a few rules to better organise my Nix code:
- Every main subdirectory only has an optional `default.nix` and subfolders for each
of its attributes.
- Inside a subdirectory, if there is non nix code, it will be in a `config` folder.
- Every module should not do anything if imported. An enable option should be toggled
for it to have any effect.
- Any nix file that represents a module should be named `default.nix` (a nix file
which is imported directly can be called anything else alongside `default.nix`)
### Flake Location
This git repo will always be located at `$FLAKE` (`config.environment.variables.FLAKE`)
and symlinked to `/etc/nixos` to have everything where NixOS tools
expect things to be.
ie.
```bash
sudo rm -r /etc/nixos
echo "$FLAKE" # /home/matt/.nix
sudo ln -sf /home/matt/.nix /etc/nixos
# Archinstaller
```
loadkeys ca
setfont ter-132b
```
### Subdirectories
| Output / Directory | Description |
| -------------------- | ----------- |
| `apps` | [Misc scripts ran from the flake](./apps) |
| `configurations` | [device, ISO and nix-on-droid configurations](./configurations) |
| `devShells` | [Development shells for a bunch of projects and languages](./devShells) |
| `homeManagerModules` | [Modules made for home-manager](./homeManagerModules) |
| `inputs` | [Pre-evaluated flake inputs](./inputs) |
| `lib` | [Custom Nix functions made easily available](./lib) |
| `modules` | [Modules made for NixOS systems](./modules) |
| `nixFastChecks` | [Attribute set of derivations exposed by this flake](./nixFastChecks) |
| `overlays` | [Nixpkgs overlays](./overlays) |
| `packages` | [Some custom packages not available in nixpkgs or modified from it](./packages) |
| `results` | Directory where I neatly keep my result symlinks from `nixFastChecks` |
| `scopedPackages` | [Some custom package scopes not available in nixpkgs or modified from it](./scopedPackages) |
### Secrets
All my secrets are in a private git repo that makes use of
[sops-nix](https://github.com/Mic92/sops-nix).
I generate `.sops.yaml` from `.sops.nix`:
```nix
let
wim = "somekey";
binto = "somekey2";
in {
creation_rules = [
{
path_regex = "secrets/[^/]+\\.(yaml|json|env|ini)$";
key_groups = [
{
age = [wim binto];
}
];
}
];
}
## Partionning with [cryptsetup](https://wiki.archlinux.org/title/Dm-crypt/Encrypting_an_entire_system#LUKS_on_a_partition)
### Encrypting root partition
```
$ PART="encrypted partition number ie. 2"
$ cryptsetup -y -v luksFormat --type luks1 /dev/nvme0n1p$PART
$ cryptsetup open /dev/nvme0n1p$PART root
$ mkfs.btrfs /dev/mapper/root
$ mount /dev/mapper/root /mnt
```
### Mounting boot :
```
$ mount --mkdir /dev/nvme0n1p1 /mnt/boot
```
which is then converted to `.sops.yaml` using
[remarshal](https://github.com/remarshal-project/remarshal)
and this shell command:
```bash
nix eval --json --file ./.sops.nix | remarshal --if json --of yaml > .sops.yaml
### Installing packages on the device
```
$ pacstrap -K /mnt base linux-firmware linux amd-ucode patch dkms kmod btrfs-progs grub os-prober ntfs-3g efibootmgr efivar networkmanager iwd nano sudo texinfo man-db man-pages
```
TLDR: I **[hate](https://ruudvanasseldonk.com/2023/01/11/the-yaml-document-from-hell)** YAML
## Preparing for chroot
```
$ genfstab -U /mnt >> /mnt/etc/fstab
$ arch-chroot /mnt
```
# Chroot in Installed Arch
```
$ ln -sf /usr/share/zoneinfo/America/Montreal /etc/localtime
$ hwclock --systohc
$ echo matt-laptop > /etc/hostname
$ passwd
```
## Localization
Uncomment ca_FR.UTF-8 en_CA.UTF-8 en_US.UTF-8 fr_CA.UTF-8 and run
```
$ locale-gen
$ echo LANG=en_CA.UTF-8 > /etc/locale.conf
$ echo KEYMAP=ca > /etc/vconsole.conf
```
## Edit /etc/mkinitcpio.conf for LUKS
```
$ sed -i 's/BINARIES=.*/BINARIES=(btrfs)/' /etc/mkinitcpio.conf
...
$ sed -i 's/HOOKS=.*/HOOKS=(base udev autodetect modconf kms keyboard keymap consolefont block encrypt filesystems fsck)/' /etc/mkinitcpio.conf
```
then run ```mkinitpcio -P```
## Grub install
```
$ grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=wim --boot-directory=/boot/EFI/wim
```
### Edit /etc/default/grub for LUKS
```
$ CRYPT="cryptdevice=$(blkid | sed -n 's/.*nvme0n1p'$PART': \(.*\) TYPE.*/\1/p'):root"
$ sed -i 's#GRUB_CMDLINE_LINUX_DEFAULT.*#GRUB_CMDLINE_LINUX_DEFAULT="quiet loglevel 3 '$CRYPT' root=/dev/mapper/root"#' /etc/default/grub
```
make sure the UUID is the actual partition inside the LUKS container and run ```grub-mkconfig -o /boot/EFI/wim/grub/grub.cfg```
we can now reboot to the installed Arch
<br/><br/>
# Inside installed Arch
## Configure [internet](https://wiki.archlinux.org/title/Iwd) access
```
$ systemctl enable --now NetworkManager systemd-networkd systemd-resolved systemd-timesyncd
$ cat << EOF >> /etc/NetworkManager/conf.d/wifi_backend.conf
[device]
wifi.backend=iwd
EOF
$ cat << EOF >> /etc/iwd/main.conf
[General]
EnableNetworkConfiguration=true
EOF
$ systemctl stop iwd
$ systemctl restart NetworkManager
$ iwctl device list # check if powered on
$ iwctl station wlan0 scan
$ iwctl station wlan0 get-networks
$ iwctl station wlan0 connect $SSID
```
### Configure systemd-resolved
```
$ ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
$ sed -i 's/#DNS=.*/DNS=100.64.0.1/' /etc/systemd/resolved.conf
$ sed -i 's/#FallbackDNS=.*/FallbackDNS=1.1.1.1/' /etc/systemd/resolved.conf
$ sed -i 's/#DNSStubListener=.*/DNSStubListener=no/' /etc/systemd/resolved.conf
```
### Configure reflector for mirror management of pacman
```
$ pacman -Sy reflector
$ nano /etc/xdg/reflector/reflector.conf
$ systemctl enable --now reflector.timer
```
## User management
```
$ useradd -m matt -G wheel,input
$ passwd matt
$ env EDITOR=nano visudo # set wheel to allow sudo commands with pass
```
## A lot of packages to install
```
$ pacman -Sy htop pkgfile mlocate rsync tmux mosh usbutils wget git curl devtools mesa lib32-mesa vulkan-radeon lib32-vulkan-radeon libva-mesa-driver lib32-libva-mesa-driver mesa-vdpau lib32-mesa-vdpau bash-completion fzf
$ pkgfile --update
```
## su matt
## Install paru
```
$ sudo pacman -S --needed git base-devel
$ git clone https://aur.archlinux.org/paru-git.git
$ cd paru-git
$ makepkg -si
$ sed -i 's/#Color/Color/' /etc/pacman.conf
$ sed -i 's/#IgnorePkg.*/IgnorePkg = linux-xanmod-anbox linux-xanmod-anbox-headers/' /etc/pacman.conf
$ cat << EOF >> /etc/paru.conf
CombinedUpgrade
BatchInstall
BottomUp
NoWarn = plymouth-theme-arch-elegant
EOF
```
## Audio
### ALSA
```
$ yay -Sy alsa-utils alsa-firmware sof-firmware alsa-ucm-conf
#unmute speakers
$ amixer sset Master unmute
```
### Pipewire
```
$ yay -Sy pipewire-audio pipewire-alsa pipewire-pulse
$ yay -R pulseaudio-alsa
$ sudo systemctl stop pulseaudio.service
$ systemctl --user enable --now pipewire-pulse.service
```
## Fingerprint Sensor Hack
```
$ yay -Sy python pam-fprint-grosshack
$ sudo systemctl enable --now fprintd
$ fprintd-enroll
```
### Use the reader
add this to the top of every file in /etc/pam.d/ that you want ie. polkit-1, sudo uwu
```
auth sufficient pam_fprintd_grosshack.so
auth sufficient pam_unix.so try_first_pass nullok
```
OR (for gtklock and check for sddm)
```
auth sufficient pam_fprintd.so
```
## Plymouth and Silent Boot
By following the wiki pages on [watchdogs](https://wiki.archlinux.org/title/Improving_performance#Watchdogs), [silent booting](https://wiki.archlinux.org/title/Silent_boot#top-page) and [Plymouth](https://wiki.archlinux.org/title/Plymouth), I edited my grub config and mkinitcpio, installed and setup Plymouth, to get a satisfying booting experience
```
$ yay -Sy plymouth-git
```
/etc/mkinitcpio.conf
```
$ sudo sed -i 's/MODULES=()/MODULES=(amdgpu)/' /etc/mkinitcpio.conf
$ sudo sed -i 's/#COMPRESSION="lz4"/COMPRESSION="lz4"/' /etc/mkinitcpio.conf
$ sudo sed -i 's/HOOKS=(.* /HOOKS=(base udev plymouth encrypt autodetect modconf kms keyboard keymap consolefont block filesystems fsck)/' /etc/mkinitcpio.conf
COMPRESSION="lz4"
```
/etc/default/grub
```
sudo sed -i 's/quiet loglevel 3/quiet splash loglevel=3 systemd.show_status=auto rd.udev.log_level=3 splash nowatchdog psi=1/' /etc/default/grub
```
Mute watchdog
```
$ echo blacklist sp5100_tco | sudo tee /etc/modprobe.d/disable-sp5100-watchdog.conf
```
Apply changes [Theme](https://github.com/murkl/plymouth-theme-arch-elegant)
```
$ git clone https://github.com/murkl/plymouth-theme-arch-elegant.git
$ cd plymouth-theme-arch-elegant/aur
$ makepkg -si
$ sudo plymouth-set-default-theme -R arch-elegant
$ sudo grub-mkconfig -o /boot/grub/grub.cfg
$ sudo sed -i 's/echo/#ech~o/g' /boot/grub/grub.cfg
```
## Here are some random changes and tweaks
### Firefox touchscreen [tweak](https://wiki.archlinux.org/title/Firefox/Tweaks#Enable_touchscreen_gestures)
```
$ echo MOZ_USE_XINPUT2 DEFAULT=1 | sudo tee -a /etc/security/pam_env.conf
```
then logout
### More Packages that are most likely needed
```
run toinstall.sh script
$ sudo reboot
```
### Flatpak
```
$ flatpak install com.github.iwalton3.jellyfin-media-player com.github.tchx84.Flatseal xournalpp stemlink
$ sudo flatpak override --filesystem=xdg-config/gtk-3.0
```
## Finally, install dotfiles
### get access to repo first
```
$ mkdir ~/git && cd ~/git
$ git clone git@git.nelim.org:matt1432/dotfiles.git
$ cd dotfiles
$ bash getenv.sh
$ sudo bash setup.sh
$ sudo bash fzf.sh /usr/share/fzf
```

View file

@ -1,116 +0,0 @@
{
inputs = import ./inputs;
outputs = inputs @ {
self,
systems,
nixpkgs,
secrets,
...
}: let
inherit (self.lib) mkVersion mkNixOS mkNixOnDroid mkPkgs;
perSystem = attrs:
nixpkgs.lib.genAttrs (import systems) (system:
attrs (mkPkgs {inherit system nixpkgs;}));
in {
lib = import ./lib {inherit inputs perSystem;};
nixOnDroidConfigurations.default =
mkNixOnDroid [./configurations/android];
nixosConfigurations = {
# Desktops
wim = mkNixOS {
extraModules = [
./configurations/wim
secrets.nixosModules.default
];
};
binto = mkNixOS {
cudaSupport = true;
extraModules = [./configurations/binto];
};
bbsteamie = mkNixOS {
mainUser = "mariah";
extraModules = [./configurations/bbsteamie];
};
# NAS
nos = mkNixOS {
cudaSupport = true;
extraModules = [
./configurations/nos
secrets.nixosModules.nos
];
};
# Build / test server
servivi = mkNixOS {
extraModules = [
./configurations/servivi
secrets.nixosModules.servivi
];
};
# Home-assistant
homie = mkNixOS {
extraModules = [
./configurations/homie
secrets.nixosModules.homie
];
};
# Cluster
thingone = mkNixOS {
extraModules = [
(import ./configurations/cluster "thingone")
secrets.nixosModules.thingy
];
};
thingtwo = mkNixOS {
extraModules = [
(import ./configurations/cluster "thingtwo")
secrets.nixosModules.thingy
];
};
live-image = mkNixOS {
mainUser = "nixos";
extraModules = [./configurations/live-image];
};
};
# For nix-fast-build. I use a custom output to alleviate eval time of this flake. ie. when doing nix flake show
nixFastChecks = import ./nixFastChecks {inherit perSystem self;};
homeManagerModules = import ./homeManagerModules {inherit self;};
nixosModules = import ./modules {inherit self;};
overlays = import ./overlays {inherit self;};
apps =
perSystem (pkgs:
import ./apps {inherit pkgs self;});
appsPackages =
perSystem (pkgs:
import ./apps/packages.nix {inherit inputs pkgs;});
devShells =
perSystem (pkgs:
import ./devShells {inherit pkgs self;});
packages =
perSystem (pkgs:
import ./packages {inherit inputs mkVersion pkgs;});
scopedPackages =
perSystem (pkgs:
import ./scopedPackages {inherit inputs mkVersion pkgs;});
formatter = perSystem (pkgs: pkgs.alejandra);
};
}

View file

@ -1,12 +0,0 @@
# Apps
This directory contains every derivations for apps exposed by this flake.
## List of my apps found in `self.apps`
| Name | Description |
| ---- | ----------- |
| `extract-subs` | Extract all `srt` subtitle files from a `mkv` video with the appropriate name. |
| `gen-docs` | Generates the READMEs in this repository from nix attributes. |
| `pin-inputs` | Takes a list of inputs to pin to their current rev in `flake.lock`. |
| `update-sources` | Updates all derivation sources in this repository and generates a commit message for the changes made. |

View file

@ -1,40 +0,0 @@
{
lib,
src,
npmDepsHash,
runtimeInputs,
buildNpmPackage,
meta,
makeWrapper,
nodejs_latest,
jq,
...
}: let
inherit (lib) concatMapStringsSep;
inherit (builtins) fromJSON readFile;
packageJSON = fromJSON (readFile "${src}/package.json");
pname = packageJSON.name;
inherit (packageJSON) version;
in
buildNpmPackage {
inherit pname version src runtimeInputs npmDepsHash;
prePatch = ''
mv ./tsconfig.json ./project.json
sed 's/^ *\/\/.*//' ${./config/tsconfig.json} > ./base.json
${jq}/bin/jq -sr '.[0] * .[1] | del(.extends)' ./project.json ./base.json > ./tsconfig.json
rm base.json project.json
'';
nativeBuildInputs = [makeWrapper];
postInstall = ''
wrapProgram $out/bin/${pname} \
--prefix PATH : ${concatMapStringsSep ":" (p: p + "/bin") runtimeInputs}
'';
nodejs = nodejs_latest;
meta = {mainProgram = pname;} // meta;
}

View file

@ -1,2 +0,0 @@
use flake $FLAKE#node
npm ci

View file

@ -1,451 +0,0 @@
import eslint from '@eslint/js';
import jsdoc from 'eslint-plugin-jsdoc';
import stylistic from '@stylistic/eslint-plugin';
import tseslint from 'typescript-eslint';
export default tseslint.config({
files: ['**/*.js', '**/*.ts'],
ignores: ['node_modules/**', 'types/**'],
extends: [
eslint.configs.recommended,
jsdoc.configs['flat/recommended-typescript'],
stylistic.configs['recommended-flat'],
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
],
rules: {
// JSDoc settings
'jsdoc/tag-lines': ['warn', 'any', { startLines: 1 }],
'jsdoc/check-line-alignment': ['warn', 'always', {
tags: ['param', 'arg', 'argument', 'property', 'prop'],
}],
'jsdoc/no-types': 'off',
// Newer settings
'@typescript-eslint/no-extraneous-class': ['off'],
'@typescript-eslint/no-implied-eval': ['off'],
'class-methods-use-this': 'off',
'@stylistic/no-multiple-empty-lines': 'off',
// Pre-flat config
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
'array-callback-return': [
'error',
{
allowImplicit: true,
checkForEach: true,
},
],
'no-constructor-return': [
'error',
],
'no-unreachable-loop': [
'error',
{
ignore: [
'ForInStatement',
'ForOfStatement',
],
},
],
'no-use-before-define': [
'error',
{
functions: false,
},
],
'block-scoped-var': [
'error',
],
'curly': [
'warn',
],
'default-case-last': [
'warn',
],
'default-param-last': [
'error',
],
'eqeqeq': [
'error',
'smart',
],
'func-names': [
'warn',
'never',
],
'func-style': [
'warn',
'expression',
],
'logical-assignment-operators': [
'warn',
'always',
],
'no-array-constructor': [
'error',
],
'no-empty-function': [
'warn',
],
'no-empty-static-block': [
'warn',
],
'no-extend-native': [
'error',
],
'no-extra-bind': [
'warn',
],
'no-implicit-coercion': [
'warn',
],
'no-iterator': [
'error',
],
'no-labels': [
'error',
],
'no-lone-blocks': [
'error',
],
'no-lonely-if': [
'error',
],
'no-loop-func': [
'error',
],
'no-magic-numbers': [
'error',
{
ignore: [
-1,
0.1,
0,
1,
2,
3,
4,
5,
10,
12,
33,
66,
100,
255,
360,
450,
500,
1000,
],
ignoreDefaultValues: true,
ignoreClassFieldInitialValues: true,
},
],
'no-multi-assign': [
'error',
],
'no-new-wrappers': [
'error',
],
'no-object-constructor': [
'error',
],
'no-proto': [
'error',
],
'no-return-assign': [
'error',
],
'no-sequences': [
'error',
],
'no-shadow': [
'error',
{
builtinGlobals: true,
allow: [
'Window',
],
},
],
'no-undef-init': [
'warn',
],
'no-undefined': [
'error',
],
'no-useless-constructor': [
'warn',
],
'no-useless-escape': [
'off',
],
'no-useless-return': [
'error',
],
'no-var': [
'error',
],
'no-void': [
'off',
],
'no-with': [
'error',
],
'object-shorthand': [
'error',
'always',
],
'one-var': [
'error',
'never',
],
'operator-assignment': [
'warn',
'always',
],
'prefer-arrow-callback': [
'error',
],
'prefer-const': [
'error',
],
'prefer-object-has-own': [
'error',
],
'prefer-regex-literals': [
'error',
],
'prefer-template': [
'warn',
],
'no-prototype-builtins': 'off',
'@typescript-eslint/no-var-requires': [
'off',
],
'@stylistic/array-bracket-newline': [
'warn',
'consistent',
],
'@stylistic/array-bracket-spacing': [
'warn',
'never',
],
'@stylistic/arrow-parens': [
'warn',
'always',
],
'@stylistic/brace-style': [
'warn',
'stroustrup',
],
'@stylistic/comma-dangle': [
'warn',
'always-multiline',
],
'@stylistic/comma-spacing': [
'warn',
{
before: false,
after: true,
},
],
'@stylistic/comma-style': [
'error',
'last',
],
'@stylistic/dot-location': [
'error',
'property',
],
'@stylistic/function-call-argument-newline': [
'warn',
'consistent',
],
'@stylistic/function-paren-newline': [
'warn',
'consistent',
],
'@stylistic/indent': [
'warn',
4,
{
SwitchCase: 1,
ignoreComments: true,
ignoredNodes: ['TemplateLiteral > *'],
},
],
'@stylistic/key-spacing': [
'warn',
{
beforeColon: false,
afterColon: true,
},
],
'@stylistic/keyword-spacing': [
'warn',
{
before: true,
},
],
'@stylistic/linebreak-style': [
'error',
'unix',
],
'@stylistic/lines-between-class-members': [
'warn',
'always',
{
exceptAfterSingleLine: true,
},
],
'@stylistic/max-len': [
'warn',
{
code: 105,
ignoreComments: true,
ignoreTrailingComments: true,
ignoreUrls: true,
},
],
'@stylistic/multiline-ternary': [
'warn',
'always-multiline',
],
'@stylistic/new-parens': [
'error',
],
'@stylistic/no-mixed-operators': [
'warn',
],
'@stylistic/no-mixed-spaces-and-tabs': [
'error',
],
'@stylistic/no-multi-spaces': [
'error',
],
'@stylistic/no-tabs': [
'error',
],
'@stylistic/no-trailing-spaces': [
'error',
],
'@stylistic/no-whitespace-before-property': [
'warn',
],
'@stylistic/nonblock-statement-body-position': [
'error',
'below',
],
'@stylistic/object-curly-newline': [
'warn',
{
consistent: true,
},
],
'@stylistic/object-curly-spacing': [
'warn',
'always',
],
'@stylistic/operator-linebreak': [
'warn',
'after',
],
'@stylistic/padded-blocks': [
'error',
'never',
],
'@stylistic/padding-line-between-statements': [
'warn',
{
blankLine: 'always',
prev: '*',
next: 'return',
},
{
blankLine: 'always',
prev: [
'const',
'let',
'var',
],
next: '*',
},
{
blankLine: 'any',
prev: [
'const',
'let',
'var',
],
next: [
'const',
'let',
'var',
],
},
{
blankLine: 'always',
prev: [
'case',
'default',
],
next: '*',
},
],
'@stylistic/quote-props': [
'error',
'consistent-as-needed',
],
'@stylistic/quotes': [
'error',
'single',
{
avoidEscape: true,
},
],
'@stylistic/semi': [
'error',
'always',
],
'@stylistic/semi-spacing': [
'warn',
],
'@stylistic/space-before-blocks': [
'warn',
],
'@stylistic/space-before-function-paren': [
'warn',
'never',
],
'@stylistic/space-infix-ops': [
'warn',
],
'@stylistic/spaced-comment': [
'warn',
'always',
],
'@stylistic/switch-colon-spacing': [
'warn',
],
'@stylistic/wrap-regex': [
'warn',
],
},
});

View file

@ -1,3 +0,0 @@
import eslintConf from './eslint.config';
export default eslintConf;

File diff suppressed because it is too large Load diff

View file

@ -1,16 +0,0 @@
{
"name": "eslint-conf",
"version": "0.0.0",
"type": "module",
"exports": "./index.ts",
"devDependencies": {
"@eslint/js": "9.20.0",
"@stylistic/eslint-plugin": "3.1.0",
"eslint": "9.20.1",
"eslint-plugin-jsdoc": "50.6.3",
"jiti": "2.4.2",
"pkg-types": "1.3.1",
"typescript": "5.7.3",
"typescript-eslint": "8.24.1"
}
}

View file

@ -1,25 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
// Env
"target": "ESNext",
"lib": [
"ESNext"
],
// Module
"module": "nodenext",
"moduleResolution": "bundler",
"baseUrl": ".",
// Emit
"noEmit": true,
"newLine": "LF",
// Interop
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
// Type Checking
"strict": true,
"noImplicitAny": false
}
}

View file

@ -1,10 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.base.json",
"includes": [
"*.ts",
"**/*.ts",
"*.js",
"**/*.js"
]
}

View file

@ -1,13 +0,0 @@
{
pkgs,
self,
...
}: let
inherit (pkgs.lib) getExe mapAttrs;
mkApp = pkg: {
program = getExe pkg;
type = "app";
};
in
mapAttrs (n: v: mkApp v) self.appsPackages.${pkgs.system}

View file

@ -1,3 +0,0 @@
use flake $FLAKE#subtitles-dev
(cd ../config; npm ci)
npm ci

View file

@ -1,17 +0,0 @@
{
buildApp,
ffmpeg-full,
...
}:
buildApp {
src = ./.;
npmDepsHash = "sha256-+NHetW6zNnJ8bubvuttwjnKGbXfwfcB0FIYpVvj7mjE=";
runtimeInputs = [
ffmpeg-full
];
meta.description = ''
Extract all `srt` subtitle files from a `mkv` video with the appropriate name.
'';
}

View file

@ -1,3 +0,0 @@
import eslintConf from 'eslint-conf';
export default eslintConf;

File diff suppressed because it is too large Load diff

View file

@ -1,21 +0,0 @@
{
"name": "extract-subs",
"version": "0.0.0",
"bin": "out/bin/app.cjs",
"type": "module",
"scripts": {
"build": "node_ver=$(node -v); esbuild src/app.ts --bundle --platform=node --target=\"node${node_ver:1:2}\" --outfile=out/bin/app.cjs"
},
"dependencies": {
"@types/fluent-ffmpeg": "2.1.27",
"fluent-ffmpeg": "2.1.3"
},
"devDependencies": {
"eslint-conf": "file:../config",
"@types/node": "22.10.10",
"esbuild": "0.24.2",
"eslint": "9.19.0",
"jiti": "2.4.2",
"typescript": "5.7.3"
}
}

View file

@ -1,157 +0,0 @@
import { spawnSync as spawn } from 'child_process';
import ffprobe from './ffprobe';
import { ISO6393To1 } from './lang-codes';
/* Types */
import { FfprobeStream } from 'fluent-ffmpeg';
const SPAWN_OPTS = {
stdio: [process.stdin, process.stdout, process.stderr],
};
/**
* These are the cli arguments
*
* @param videoPath the directory in which we want to sync the subtitles
* @param languages a comma-separated list of languages (3 letters) to sync the subtitles
*/
const video = process.argv[2];
const languages = process.argv[3]?.split(',');
// Global Vars
const subIndexes: number[] = [];
let videoPath: string;
let baseName: string;
/**
* Gets the relative path to the subtitle file of a ffmpeg stream.
*
* @param sub the stream of the subtitles to extract
* @returns the path of the subtitle file
*/
const getSubPath = (sub: FfprobeStream): string => {
const language = ISO6393To1.get(sub.tags.language);
const forced = sub.disposition?.forced === 0 ?
'' :
'.forced';
const hearingImpaired = sub.disposition?.hearing_impaired === 0 ?
'' :
'.sdh';
return `${baseName}${forced}.${language}${hearingImpaired}.srt`;
};
/**
* Removes all subtitles streams from the video file.
*/
const removeContainerSubs = (): void => {
spawn('mv', [
videoPath,
`${videoPath}.bak`,
], SPAWN_OPTS);
spawn('ffmpeg', [
'-i', `${videoPath}.bak`,
'-map', '0',
...subIndexes.map((i) => ['-map', `-0:${i}`]).flat(),
'-c', 'copy', videoPath,
], SPAWN_OPTS);
spawn('rm', [
`${videoPath}.bak`,
], SPAWN_OPTS);
};
/**
* Extracts a sub of a video file to a subtitle file.
*
* @param sub the stream of the subtitles to extract
*/
const extractSub = (sub: FfprobeStream): void => {
const subFile = getSubPath(sub);
spawn('ffmpeg', [
'-i', videoPath,
'-map', `0:${sub.index}`, subFile,
], SPAWN_OPTS);
subIndexes.push(sub.index);
};
/**
* Sorts the list of streams to only keep subtitles
* that can be extracted.
*
* @param lang the language of the subtitles
* @param streams the streams
* @returns the streams that represent subtitles
*/
const findSubs = (
lang: string,
streams: FfprobeStream[],
): FfprobeStream[] => {
const subs = streams.filter((s) => s.tags?.language &&
s.tags.language === lang &&
s.codec_type === 'subtitle');
const pgs = subs.filter((s) => s.codec_name === 'hdmv_pgs_subtitle');
// If we only have PGS subs, warn user
if (pgs.length === subs.length) {
console.warn(`No SRT subtitle tracks were found for ${lang}`);
}
// Remove PGS streams from subs
return subs.filter((s) => s.codec_name !== 'hdmv_pgs_subtitle');
};
/**
* Where the magic happens.
*/
const main = async(): Promise<void> => {
// Get rid of video extension
baseName = videoPath.split('/').at(-1)!.replace(/\.[^.]*$/, '');
// ffprobe the video file to see available sub tracks
const data = await ffprobe(videoPath);
if (!data?.streams) {
return;
}
// Check for languages wanted
languages.forEach((lang) => {
const subs = findSubs(lang, data.streams);
if (subs.length === 0) {
console.warn(`No subtitle tracks were found for ${lang}`);
return;
}
// Extract all subs
subs.forEach((sub) => {
extractSub(sub);
});
});
removeContainerSubs();
};
// Check if there are 2 params
if (video && languages) {
videoPath = video;
main();
}
else {
console.error('Error: no argument passed');
process.exit(1);
}

View file

@ -1,8 +0,0 @@
import Ffmpeg from 'fluent-ffmpeg';
export default (videoPath: string) => new Promise<Ffmpeg.FfprobeData>((resolve) => {
Ffmpeg.ffprobe(videoPath, (_e, data) => {
resolve(data);
});
});

View file

@ -1,373 +0,0 @@
export const ISO6391To3 = new Map([
['aa', 'aar'],
['ab', 'abk'],
['af', 'afr'],
['ak', 'aka'],
['am', 'amh'],
['ar', 'ara'],
['an', 'arg'],
['as', 'asm'],
['av', 'ava'],
['ae', 'ave'],
['ay', 'aym'],
['az', 'aze'],
['ba', 'bak'],
['bm', 'bam'],
['be', 'bel'],
['bn', 'ben'],
['bi', 'bis'],
['bo', 'bod'],
['bs', 'bos'],
['br', 'bre'],
['bg', 'bul'],
['ca', 'cat'],
['cs', 'ces'],
['ch', 'cha'],
['ce', 'che'],
['cu', 'chu'],
['cv', 'chv'],
['kw', 'cor'],
['co', 'cos'],
['cr', 'cre'],
['cy', 'cym'],
['da', 'dan'],
['de', 'deu'],
['dv', 'div'],
['dz', 'dzo'],
['el', 'ell'],
['en', 'eng'],
['eo', 'epo'],
['et', 'est'],
['eu', 'eus'],
['ee', 'ewe'],
['fo', 'fao'],
['fa', 'fas'],
['fj', 'fij'],
['fi', 'fin'],
['fr', 'fre'],
['fy', 'fry'],
['ff', 'ful'],
['gd', 'gla'],
['ga', 'gle'],
['gl', 'glg'],
['gv', 'glv'],
['gn', 'grn'],
['gu', 'guj'],
['ht', 'hat'],
['ha', 'hau'],
['sh', 'hbs'],
['he', 'heb'],
['hz', 'her'],
['hi', 'hin'],
['ho', 'hmo'],
['hr', 'hrv'],
['hu', 'hun'],
['hy', 'hye'],
['ig', 'ibo'],
['io', 'ido'],
['ii', 'iii'],
['iu', 'iku'],
['ie', 'ile'],
['ia', 'ina'],
['id', 'ind'],
['ik', 'ipk'],
['is', 'isl'],
['it', 'ita'],
['jv', 'jav'],
['ja', 'jpn'],
['kl', 'kal'],
['kn', 'kan'],
['ks', 'kas'],
['ka', 'kat'],
['kr', 'kau'],
['kk', 'kaz'],
['km', 'khm'],
['ki', 'kik'],
['rw', 'kin'],
['ky', 'kir'],
['kv', 'kom'],
['kg', 'kon'],
['ko', 'kor'],
['kj', 'kua'],
['ku', 'kur'],
['lo', 'lao'],
['la', 'lat'],
['lv', 'lav'],
['li', 'lim'],
['ln', 'lin'],
['lt', 'lit'],
['lb', 'ltz'],
['lu', 'lub'],
['lg', 'lug'],
['mh', 'mah'],
['ml', 'mal'],
['mr', 'mar'],
['mk', 'mkd'],
['mg', 'mlg'],
['mt', 'mlt'],
['mn', 'mon'],
['mi', 'mri'],
['ms', 'msa'],
['my', 'mya'],
['na', 'nau'],
['nv', 'nav'],
['nr', 'nbl'],
['nd', 'nde'],
['ng', 'ndo'],
['ne', 'nep'],
['nl', 'nld'],
['nn', 'nno'],
['nb', 'nob'],
['no', 'nor'],
['ny', 'nya'],
['oc', 'oci'],
['oj', 'oji'],
['or', 'ori'],
['om', 'orm'],
['os', 'oss'],
['pa', 'pan'],
['pi', 'pli'],
['pl', 'pol'],
['pt', 'por'],
['ps', 'pus'],
['qu', 'que'],
['rm', 'roh'],
['ro', 'ron'],
['rn', 'run'],
['ru', 'rus'],
['sg', 'sag'],
['sa', 'san'],
['si', 'sin'],
['sk', 'slk'],
['sl', 'slv'],
['se', 'sme'],
['sm', 'smo'],
['sn', 'sna'],
['sd', 'snd'],
['so', 'som'],
['st', 'sot'],
['es', 'spa'],
['sq', 'sqi'],
['sc', 'srd'],
['sr', 'srp'],
['ss', 'ssw'],
['su', 'sun'],
['sw', 'swa'],
['sv', 'swe'],
['ty', 'tah'],
['ta', 'tam'],
['tt', 'tat'],
['te', 'tel'],
['tg', 'tgk'],
['tl', 'tgl'],
['th', 'tha'],
['ti', 'tir'],
['to', 'ton'],
['tn', 'tsn'],
['ts', 'tso'],
['tk', 'tuk'],
['tr', 'tur'],
['tw', 'twi'],
['ug', 'uig'],
['uk', 'ukr'],
['ur', 'urd'],
['uz', 'uzb'],
['ve', 'ven'],
['vi', 'vie'],
['vo', 'vol'],
['wa', 'wln'],
['wo', 'wol'],
['xh', 'xho'],
['yi', 'yid'],
['yo', 'yor'],
['za', 'zha'],
['zh', 'zho'],
['zu', 'zul'],
]);
export const ISO6393To1 = new Map([
['aar', 'aa'],
['abk', 'ab'],
['afr', 'af'],
['aka', 'ak'],
['amh', 'am'],
['ara', 'ar'],
['arg', 'an'],
['asm', 'as'],
['ava', 'av'],
['ave', 'ae'],
['aym', 'ay'],
['aze', 'az'],
['bak', 'ba'],
['bam', 'bm'],
['bel', 'be'],
['ben', 'bn'],
['bis', 'bi'],
['bod', 'bo'],
['bos', 'bs'],
['bre', 'br'],
['bul', 'bg'],
['cat', 'ca'],
['ces', 'cs'],
['cha', 'ch'],
['che', 'ce'],
['chu', 'cu'],
['chv', 'cv'],
['cor', 'kw'],
['cos', 'co'],
['cre', 'cr'],
['cym', 'cy'],
['dan', 'da'],
['deu', 'de'],
['div', 'dv'],
['dzo', 'dz'],
['ell', 'el'],
['eng', 'en'],
['epo', 'eo'],
['est', 'et'],
['eus', 'eu'],
['ewe', 'ee'],
['fao', 'fo'],
['fas', 'fa'],
['fij', 'fj'],
['fin', 'fi'],
['fre', 'fr'],
['fry', 'fy'],
['ful', 'ff'],
['gla', 'gd'],
['gle', 'ga'],
['glg', 'gl'],
['glv', 'gv'],
['grn', 'gn'],
['guj', 'gu'],
['hat', 'ht'],
['hau', 'ha'],
['hbs', 'sh'],
['heb', 'he'],
['her', 'hz'],
['hin', 'hi'],
['hmo', 'ho'],
['hrv', 'hr'],
['hun', 'hu'],
['hye', 'hy'],
['ibo', 'ig'],
['ido', 'io'],
['iii', 'ii'],
['iku', 'iu'],
['ile', 'ie'],
['ina', 'ia'],
['ind', 'id'],
['ipk', 'ik'],
['isl', 'is'],
['ita', 'it'],
['jav', 'jv'],
['jpn', 'ja'],
['kal', 'kl'],
['kan', 'kn'],
['kas', 'ks'],
['kat', 'ka'],
['kau', 'kr'],
['kaz', 'kk'],
['khm', 'km'],
['kik', 'ki'],
['kin', 'rw'],
['kir', 'ky'],
['kom', 'kv'],
['kon', 'kg'],
['kor', 'ko'],
['kua', 'kj'],
['kur', 'ku'],
['lao', 'lo'],
['lat', 'la'],
['lav', 'lv'],
['lim', 'li'],
['lin', 'ln'],
['lit', 'lt'],
['ltz', 'lb'],
['lub', 'lu'],
['lug', 'lg'],
['mah', 'mh'],
['mal', 'ml'],
['mar', 'mr'],
['mkd', 'mk'],
['mlg', 'mg'],
['mlt', 'mt'],
['mon', 'mn'],
['mri', 'mi'],
['msa', 'ms'],
['mya', 'my'],
['nau', 'na'],
['nav', 'nv'],
['nbl', 'nr'],
['nde', 'nd'],
['ndo', 'ng'],
['nep', 'ne'],
['nld', 'nl'],
['nno', 'nn'],
['nob', 'nb'],
['nor', 'no'],
['nya', 'ny'],
['oci', 'oc'],
['oji', 'oj'],
['ori', 'or'],
['orm', 'om'],
['oss', 'os'],
['pan', 'pa'],
['pli', 'pi'],
['pol', 'pl'],
['por', 'pt'],
['pus', 'ps'],
['que', 'qu'],
['roh', 'rm'],
['ron', 'ro'],
['run', 'rn'],
['rus', 'ru'],
['sag', 'sg'],
['san', 'sa'],
['sin', 'si'],
['slk', 'sk'],
['slv', 'sl'],
['sme', 'se'],
['smo', 'sm'],
['sna', 'sn'],
['snd', 'sd'],
['som', 'so'],
['sot', 'st'],
['spa', 'es'],
['sqi', 'sq'],
['srd', 'sc'],
['srp', 'sr'],
['ssw', 'ss'],
['sun', 'su'],
['swa', 'sw'],
['swe', 'sv'],
['tah', 'ty'],
['tam', 'ta'],
['tat', 'tt'],
['tel', 'te'],
['tgk', 'tg'],
['tgl', 'tl'],
['tha', 'th'],
['tir', 'ti'],
['ton', 'to'],
['tsn', 'tn'],
['tso', 'ts'],
['tuk', 'tk'],
['tur', 'tr'],
['twi', 'tw'],
['uig', 'ug'],
['ukr', 'uk'],
['urd', 'ur'],
['uzb', 'uz'],
['ven', 've'],
['vie', 'vi'],
['vol', 'vo'],
['wln', 'wa'],
['wol', 'wo'],
['xho', 'xh'],
['yid', 'yi'],
['yor', 'yo'],
['zha', 'za'],
['zho', 'zh'],
['zul', 'zu'],
]);

View file

@ -1,10 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../config/tsconfig.base.json",
"includes": [
"*.ts",
"**/*.ts",
"*.js",
"**/*.js"
]
}

View file

@ -1,15 +0,0 @@
{
writeShellApplication,
jq,
pandoc,
...
}:
writeShellApplication {
name = "gen-docs";
runtimeInputs = [jq pandoc];
text = builtins.readFile ./script.sh;
meta.description = ''
Generates the READMEs in this repository from nix attributes.
'';
}

View file

@ -1,13 +0,0 @@
attr: selfPath: let
inherit (builtins) mapAttrs replaceStrings;
modules = import "${selfPath}/${attr}" {description = true;};
trimNewlines = s: replaceStrings ["\n"] [" "] s;
in {
attrs =
mapAttrs (_: v: {
desc = trimNewlines v;
})
modules;
}

View file

@ -1,12 +0,0 @@
configs: let
inherit (builtins) mapAttrs replaceStrings;
trimNewlines = s: replaceStrings ["\n"] [" "] s;
in {
attrs =
mapAttrs (_: v: {
roleDesc = trimNewlines (v.config.meta.roleDescription or "");
hwDesc = trimNewlines (v.config.meta.hardwareDescription or "");
})
configs;
}

View file

@ -1,13 +0,0 @@
x: let
inherit (builtins) currentSystem mapAttrs removeAttrs replaceStrings;
trimNewlines = s: replaceStrings ["\n"] [" "] s;
packages = removeAttrs x.${currentSystem} ["default"];
in {
attrs =
mapAttrs (_: v: {
desc = trimNewlines (v.meta.description or "");
homepage = v.meta.homepage or "";
})
packages;
}

View file

@ -1,31 +0,0 @@
attr: selfPath: let
inherit (builtins) currentSystem getFlake mapAttrs removeAttrs replaceStrings;
self = getFlake selfPath;
scopes = import "${selfPath}/${attr}" {description = true;};
trimNewlines = s: replaceStrings ["\n"] [" "] s;
in {
attrs =
mapAttrs (n: v: {
desc = trimNewlines v;
packages = let
scopePkgs = removeAttrs self.${attr}.${currentSystem}.${n} [
"buildFirefoxXpiAddon"
"callPackage"
"newScope"
"override"
"overrideDerivation"
"overrideScope"
"packages"
"recurseForDerivations"
];
in
mapAttrs (_: pkg: {
desc = trimNewlines (pkg.meta.description or "");
homepage = pkg.meta.homepage or "";
})
scopePkgs;
})
scopes;
}

View file

@ -1,43 +0,0 @@
substituteDerivs() {
echo '' | pandoc --metadata-file <(
nix eval \
--impure \
--json \
"$FLAKE"#"$1" \
--apply "import \"$FLAKE/apps/gen-docs/$3.nix\"" |
jq -r
) -t markdown --template "$FLAKE/apps/gen-docs/templates/$2.md" -o "$FLAKE/$2/README.md"
}
substituteAttrs() {
echo '' | pandoc --metadata-file <(
nix eval \
--impure \
--json \
--expr "\"$FLAKE\"" \
--apply "(import \"$FLAKE/apps/gen-docs/getAttrsMeta.nix\") \"$1\"" |
jq -r
) -t markdown --template "$FLAKE/apps/gen-docs/templates/$1.md" -o "$FLAKE/$1/README.md"
}
substituteScopes() {
echo '' | pandoc --metadata-file <(
nix eval \
--impure \
--json \
--expr "\"$FLAKE\"" \
--apply "(import \"$FLAKE/apps/gen-docs/getScopesMeta.nix\") \"$1\"" |
jq -r
) -t markdown --template "$FLAKE/apps/gen-docs/templates/$1.md" -o "$FLAKE/$1/README.md"
}
substituteDerivs "appsPackages" "apps" "getPackageMeta"
substituteDerivs "nixosConfigurations" "configurations" "getConfigMeta"
substituteDerivs "devShells" "devShells" "getPackageMeta"
substituteDerivs "packages" "packages" "getPackageMeta"
substituteAttrs "modules"
substituteAttrs "homeManagerModules"
substituteAttrs "overlays"
substituteScopes "scopedPackages"

View file

@ -1,11 +0,0 @@
# Apps
This directory contains every derivations for apps exposed by this flake.
## List of my apps found in `self.apps`
| Name | Description |
| ---- | ----------- |
$for(attrs/pairs)$
| `$it.key$` | $it.value.desc/nowrap$ |
$endfor$

View file

@ -1,13 +0,0 @@
# NixosConfigurations
This directory contains every device's main configuration file, their `hardware-configuration.nix` and some custom modules
unique to them.
## List of my devices
| Name | Model / Specs | Description |
| --------- | ------------- | ------------------------------------------------------------------------------------------------ |
| `android` | OnePlus 9 Pro | [Nix-On-Droid](https://github.com/nix-community/nix-on-droid) configuration for my OnePlus 9 Pro |
$for(attrs/pairs)$
| `$it.key$` | $it.value.hwDesc/nowrap$ | $it.value.roleDesc/nowrap$ |
$endfor$

View file

@ -1,11 +0,0 @@
# DevShells
This directory contains every derivations for devShells exposed by this flake.
## List of my devShells found in `self.devShells`
| Name | Description |
| ---- | ----------- |
$for(attrs/pairs)$
| `$it.key$` | $it.value.desc/nowrap$ |
$endfor$

View file

@ -1,11 +0,0 @@
# HomeManagerModules
This directory contains every home-manager modules exposed by this flake.
## List of my home-manager modules found in `self.homeManagerModules`
| Name | Description |
| ---- | ----------- |
$for(attrs/pairs)$
| `$it.key$` | $it.value.desc/nowrap$ |
$endfor$

View file

@ -1,11 +0,0 @@
# NixosModules
This directory contains every modules for NixOS exposed by this flake.
## List of my modules found in `self.nixosModules`
| Name | Description |
| ---- | ----------- |
$for(attrs/pairs)$
| `$it.key$` | $it.value.desc/nowrap$ |
$endfor$

View file

@ -1,11 +0,0 @@
# Overlays
This directory contains every overlay exposed by this flake.
## List of my overlays found in `self.overlays`
| Name | Description |
| ---- | ----------- |
$for(attrs/pairs)$
| `$it.key$` | $it.value.desc/nowrap$ |
$endfor$

View file

@ -1,11 +0,0 @@
# Packages
This directory contains every derivations for packages exposed by this flake.
## List of my packages found in `self.packages`
| Name | Description | Homepage |
| ---- | ----------- | -------- |
$for(attrs/pairs)$
| `$it.key$` | $it.value.desc/nowrap$ | $it.value.homepage/nowrap$ |
$endfor$

View file

@ -1,18 +0,0 @@
# ScopedPackages
This directory contains every package scopes exposed by this flake.
## List of my package scopes found in `self.scopedPackages`
$for(attrs/pairs)$
### $it.key$
$it.value.desc/nowrap$
| Name | Description | Homepage |
| ---- | ----------- | -------- |
$for(it.value.packages/pairs)$
| `$it.key$` | $it.value.desc/nowrap$ | $it.value.homepage/nowrap$ |
$endfor$
$endfor$

View file

@ -1,16 +0,0 @@
{
inputs,
pkgs,
...
}: let
inherit (pkgs.lib) listToAttrs nameValuePair;
buildApp = attrs: (pkgs.callPackage ./buildApp.nix ({} // inputs // attrs));
callPackage = file: pkgs.callPackage file ({inherit buildApp;} // inputs);
in
listToAttrs (map (x: nameValuePair x (callPackage ./${x})) [
"extract-subs"
"gen-docs"
"pin-inputs"
"update-sources"
])

View file

@ -1,3 +0,0 @@
use flake $FLAKE#node
(cd ../config; npm ci)
npm ci

View file

@ -1,11 +0,0 @@
{buildApp, ...}:
buildApp {
src = ./.;
npmDepsHash = "sha256-qNTgtT+x1O1jMWYgs8pXy3fUJKHBnf9adhR9nD5V7TY=";
runtimeInputs = [];
meta.description = ''
Takes a list of inputs to pin to their current rev in `flake.lock`.
'';
}

View file

@ -1,3 +0,0 @@
import eslintConf from 'eslint-conf';
export default eslintConf;

File diff suppressed because it is too large Load diff

View file

@ -1,18 +0,0 @@
{
"name": "pin-inputs",
"version": "0.0.0",
"bin": "out/bin/app.cjs",
"type": "module",
"scripts": {
"build": "node_ver=$(node -v); esbuild src/app.ts --bundle --platform=node --target=\"node${node_ver:1:2}\" --outfile=out/bin/app.cjs"
},
"devDependencies": {
"eslint-conf": "file:../config",
"@types/node": "22.12.0",
"esbuild": "0.24.2",
"eslint": "9.19.0",
"jiti": "2.4.2",
"pkg-types": "1.3.1",
"typescript": "5.7.3"
}
}

View file

@ -1,62 +0,0 @@
import { readFileSync, writeFileSync } from 'fs';
export const replaceInFile = (replace: RegExp, replacement: string, file: string) => {
const fileContents = readFileSync(file);
const replaced = fileContents.toString().replace(replace, replacement);
writeFileSync(file, replaced);
};
/* Constants */
const FLAKE = process.env.FLAKE;
if (!FLAKE) {
console.error('Environment variable FLAKE not found');
process.exit(1);
}
const FLAKE_LOCK = JSON.parse(readFileSync(`${FLAKE}/flake.lock`, 'utf8')).nodes;
const INPUT_REVS = new Map<string, string>();
Object.entries(FLAKE_LOCK).forEach(([key, val]) => {
if (key !== 'root') {
// eslint-disable-next-line
INPUT_REVS.set(key, (val as any).locked.rev);
}
});
const INPUTS = process.argv.slice(2);
/**
* Gets the commit hash of the specified input in this flake.
*
* @param input the name of the input
* @returns the commit hash
*/
const getCurrentRev = (input: string): string => {
if (!INPUT_REVS.has(input)) {
throw new Error(`Input ${input} could not be found.`);
}
return INPUT_REVS.get(input) as string;
};
INPUTS.forEach((input) => {
try {
const inputsFile = `${FLAKE}/inputs/default.nix`;
const rev = getCurrentRev(input);
const msg = ['FIX', 'ME'].join('');
replaceInFile(
new RegExp(`(\\n[ ]*)${input} =.*\\n.*\\n.*`),
`$&\n$1 # ${msg}: $1 rev = "${rev}";`,
inputsFile,
);
}
catch (e) {
console.error((e as Error).message);
}
});

View file

@ -1,10 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../config/tsconfig.base.json",
"includes": [
"*.ts",
"**/*.ts",
"*.js",
"**/*.js"
]
}

View file

@ -1,3 +0,0 @@
use flake $FLAKE#node
(cd ../config; npm ci)
npm ci

View file

@ -1,32 +0,0 @@
{
buildApp,
callPackage,
curl,
findutils,
go,
jq,
nix-update,
nodejs_latest,
prefetch-npm-deps,
...
}:
buildApp {
src = ./.;
npmDepsHash = "sha256-2cWxVTCOEJOg2eBv+xX/mvr6MUX+UJQ8JlkoObD6+Uc=";
runtimeInputs = [
curl
findutils
go
jq
nix-update
nodejs_latest
prefetch-npm-deps
(callPackage ../../modules/docker/updateImage.nix {})
];
meta.description = ''
Updates all derivation sources in this repository and
generates a commit message for the changes made.
'';
}

View file

@ -1,3 +0,0 @@
import eslintConf from 'eslint-conf';
export default eslintConf;

File diff suppressed because it is too large Load diff

View file

@ -1,18 +0,0 @@
{
"name": "update-sources",
"version": "0.0.0",
"bin": "out/bin/app.cjs",
"type": "module",
"scripts": {
"build": "node_ver=$(node -v); esbuild src/app.ts --bundle --platform=node --target=\"node${node_ver:1:2}\" --outfile=out/bin/app.cjs"
},
"devDependencies": {
"eslint-conf": "file:../config",
"@types/node": "22.13.4",
"esbuild": "0.25.0",
"eslint": "9.20.1",
"jiti": "2.4.2",
"pkg-types": "1.3.1",
"typescript": "5.7.3"
}
}

View file

@ -1,188 +0,0 @@
import { spawnSync } from 'node:child_process';
import { writeFileSync } from 'node:fs';
import { parseArgs } from './lib';
import { updateDocker } from './docker';
import { updateFirefoxAddons } from '././firefox';
import { updateFlakeInputs } from './flake';
import updateNodeModules from './node-modules';
import {
runNixUpdate,
updateCaddyPlugins,
updateVuetorrent,
} from './misc';
/* Constants */
const FLAKE = process.env.FLAKE;
if (!FLAKE) {
console.error('Env var FLAKE not found');
process.exit(1);
}
const args = parseArgs();
const main = async() => {
if (args['c'] || args['custom-sidebar']) {
console.log(runNixUpdate('scopedPackages', 'lovelace-components', 'custom-sidebar'));
}
if (args['cp'] || args['caddy-plugins']) {
console.log(updateCaddyPlugins());
}
if (args['d'] || args['docker']) {
console.log(updateDocker());
}
if (args['f'] || args['firefox']) {
console.log(updateFirefoxAddons());
}
if (args['h'] || args['homepage']) {
console.log(runNixUpdate('homepage'));
}
if (args['i'] || args['inputs']) {
console.log(updateFlakeInputs());
}
if (args['j'] || args['jmusicbot']) {
console.log(runNixUpdate('jmusicbot'));
}
if (args['m'] || args['material-rounded-theme']) {
console.log(runNixUpdate('scopedPackages', 'lovelace-components', 'material-rounded-theme'));
}
if (args['n'] || args['node_modules']) {
console.log(await updateNodeModules());
}
if (args['p'] || args['pam-fprint-grosshack']) {
console.log(runNixUpdate('pam-fprint-grosshack'));
}
if (args['ph'] || args['protonhax']) {
console.log(runNixUpdate('protonhax'));
}
if (args['s'] || args['some-sass-language-server']) {
console.log(runNixUpdate('some-sass-language-server'));
}
if (args['t'] || args['trash-d']) {
console.log(runNixUpdate('trash-d'));
}
if (args['v'] || args['vuetorrent']) {
console.log(updateVuetorrent());
}
if (args['a'] || args['all']) {
// Update this first because of nix run cmd
const firefoxOutput = updateFirefoxAddons();
console.log(firefoxOutput);
const flakeOutput = updateFlakeInputs();
console.log(flakeOutput);
const dockerOutput = updateDocker();
console.log(dockerOutput);
const nodeModulesOutput = await updateNodeModules();
console.log(nodeModulesOutput);
const vuetorrentOutput = updateVuetorrent();
console.log(vuetorrentOutput);
const caddyPluginsOutput = updateCaddyPlugins();
console.log(caddyPluginsOutput);
// nix-update executions
let nixUpdateOutputs = '';
const updatePackage = (
attr: string,
scope?: string,
scopeAttr?: string,
): void => {
const execution = runNixUpdate(attr, scope, scopeAttr);
nixUpdateOutputs += execution.stdout;
console.log(execution.stderr);
console.log(execution.stdout);
};
updatePackage('homepage');
updatePackage('jmusicbot');
updatePackage('pam-fprint-grosshack');
updatePackage('protonhax');
updatePackage('some-sass-language-server');
updatePackage('trash-d');
updatePackage('scopedPackages', 'lovelace-components', 'custom-sidebar');
updatePackage('scopedPackages', 'lovelace-components', 'material-rounded-theme');
spawnSync('nixFastBuild', [], {
shell: true,
stdio: [process.stdin, process.stdout, process.stderr],
});
const indentOutput = (output: string): string => {
return ` ${output.split('\n').join('\n ')}`;
};
const output = [
'chore: update sources\n\n',
];
if (flakeOutput.length > 5) {
output.push(`Flake Inputs:\n${indentOutput(flakeOutput)}\n\n`);
}
if (dockerOutput.length > 5) {
output.push(`Docker Images:\n${indentOutput(dockerOutput)}\n`);
}
if (firefoxOutput.length > 5) {
output.push(`Firefox Addons:\n${indentOutput(firefoxOutput)}\n\n`);
}
if (nodeModulesOutput.length > 5) {
output.push(`Node modules:\n${indentOutput(nodeModulesOutput)}\n`);
}
if (vuetorrentOutput.length > 5) {
output.push(`Misc Sources:\n${indentOutput(vuetorrentOutput)}\n\n`);
}
if (caddyPluginsOutput.length > 5) {
output.push(`Caddy Plugins:\n${indentOutput(caddyPluginsOutput)}\n\n`);
}
if (nixUpdateOutputs.length > 5) {
output.push(`nix-update executions:\n${indentOutput(nixUpdateOutputs)}\n`);
}
if (args['f']) {
writeFileSync(args['f'] as string, output.join(''));
}
else {
console.log(output.join(''));
}
}
spawnSync('alejandra', ['-q', FLAKE], { shell: true });
};
main();

View file

@ -1,33 +0,0 @@
import { readdirSync } from 'node:fs';
import { spawnSync } from 'node:child_process';
/* Constants */
const FLAKE = process.env.FLAKE;
const updateImages = (imagePath: string): string | undefined => {
console.log(`Updating ${imagePath.split('/').at(-1)} images`);
const out = spawnSync('updateImages', [imagePath], { shell: true }).stdout.toString();
if (!out.startsWith('# Locked')) {
return out;
}
};
export const updateDocker = () => {
let updates = '';
updates += updateImages(`${FLAKE}/configurations/nos/modules/jellyfin`) ?? '';
updates += updateImages(`${FLAKE}/configurations/homie/modules/home-assistant/netdaemon`) ?? '';
const DIR = `${FLAKE}/configurations/nos/modules/docker`;
readdirSync(DIR, { withFileTypes: true, recursive: true }).forEach((path) => {
if (path.name === 'compose.nix') {
updates += updateImages(path.parentPath) ?? '';
}
});
return updates;
};

View file

@ -1,61 +0,0 @@
import { spawnSync } from 'node:child_process';
import { readFileSync } from 'node:fs';
/* Constants */
const FLAKE = process.env.FLAKE;
export const updateFirefoxAddons = () => {
console.log('Updating firefox addons using mozilla-addons-to-nix');
const DIR = `${FLAKE}/scopedPackages/firefox-addons`;
const GENERATED_FILE = `${DIR}/generated-firefox-addons.nix`;
const SLUGS = `${DIR}/addons.json`;
const nameMap = Object.fromEntries([...JSON.parse(readFileSync(SLUGS, 'utf-8'))]
.map((addon) => [addon.slug, addon.pname || addon.slug]));
const nixExpr = `'
x: let
inherit (builtins) attrValues filter hasAttr isAttrs map;
in
map (d: d.name) (filter (y:
isAttrs y &&
hasAttr "type" y &&
y.type == "derivation") (attrValues x))
'`;
const OLD_VERS = Object.fromEntries([...JSON.parse(spawnSync('nix', [
'eval',
'.#scopedPackages.x86_64-linux.firefoxAddons',
'--apply',
nixExpr,
'--json',
], { shell: true }).stdout.toString())]
.map((p) => {
const pname = p.replace(/-[0-9].*$/, '');
return [pname, p.replace(`${pname}-`, '')];
})
.filter((pinfo) => pinfo[0] !== 'frankerfacez'));
const NEW_VERS = Object.fromEntries(spawnSync(
'nix',
['run', 'sourcehut:~rycee/mozilla-addons-to-nix',
SLUGS, GENERATED_FILE],
{ shell: true },
).stdout
.toString()
.split('\n')
.map((p) => {
const pinfo = p.replace('Fetched ', '').split(' ');
return [nameMap[pinfo[0]], pinfo[2]];
}));
return Object.keys(OLD_VERS)
.sort()
.filter((pname) => OLD_VERS[pname] !== NEW_VERS[pname])
.map((pname) => `${pname}: ${OLD_VERS[pname]} -> ${NEW_VERS[pname]}`)
.join('\n');
};

View file

@ -1,45 +0,0 @@
import { spawnSync } from 'node:child_process';
/* Constants */
const FLAKE = process.env.FLAKE;
export const updateFlakeInputs = () => {
const output = spawnSync(
`git restore flake.lock &> /dev/null; nix flake update --flake ${FLAKE}` +
' |& grep -v "warning: updating lock file" |& grep -v "unpacking"',
[],
{ shell: true },
).stdout
.toString()
// Add an extra blank line between inputs
.split('\n•')
// Filter out some inputs
.filter((input) => ![
'systems',
'flake-compat',
'flake-utils',
'flake-parts',
'treefmt-nix',
'lib-aggregate',
'lib-aggregate/nixpkgs-lib',
'nix-gaming/umu',
'nix-github-actions',
'pre-commit-hooks',
].some((inputName) => input.startsWith(` Updated input '${inputName}'`)))
.join('\n\n•')
// help readability of git revs
.split('\n')
.map((l) => l
.replace(
/\/(.{40})\?narHash=sha256[^']*(.*)/,
(_, backref1, backref2) => `${backref2} rev: ${backref1}`,
)
.replace(
/\?ref.*&rev=(.{40})[^'&]*(.*)/,
(_, backref1, backref2) => `${backref2} rev: ${backref1}`,
))
.join('\n');
return output;
};

View file

@ -1,43 +0,0 @@
import { spawnSync } from 'node:child_process';
import { readFileSync, writeFileSync } from 'node:fs';
export const parseArgs = () => {
const args = {} as Record<string, unknown>;
let lastFlag: string | null = null;
for (let i = 2; i < process.argv.length; ++i) {
const arg = process.argv[i];
if (arg.toString().startsWith('-')) {
lastFlag = arg.toString().replace(/^-{1,2}/, '');
args[lastFlag] = true;
}
else if (lastFlag) {
args[lastFlag] = arg;
lastFlag = null;
}
else {
console.error(`Could not parse args: ${arg.toString()}`);
}
}
return args;
};
export const parseFetchurl = (url: string) => JSON.parse(spawnSync(
'nix', ['store', 'prefetch-file', '--refresh', '--json',
'--hash-type', 'sha256', url, '--name', '"escaped"'], { shell: true },
).stdout.toString()).hash;
export const replaceInFile = (replace: RegExp, replacement: string, file: string) => {
const fileContents = readFileSync(file);
const replaced = fileContents.toString().replace(replace, replacement);
writeFileSync(file, replaced);
};
export const npmRun = (args: string[], workspaceDir: string) => spawnSync(
'npm', args, { cwd: workspaceDir },
).stdout.toString();

View file

@ -1,161 +0,0 @@
import { writeFileSync } from 'node:fs';
import { spawnSync } from 'node:child_process';
import { parseFetchurl, replaceInFile } from './lib';
/* Constants */
const FLAKE = process.env.FLAKE;
const genVueText = (
version: string,
hash: string,
url: string,
) => `# This file was autogenerated. DO NOT EDIT!
{
version = "${version}";
url = "${url}";
hash = "${hash}";
}
`;
export const updateVuetorrent = () => {
const FILE = `${FLAKE}/configurations/nos/modules/qbittorrent/vuetorrent.nix`;
const OLD_VERSION = JSON.parse(spawnSync('nix',
['eval', '-f', FILE, '--json'],
{ shell: true }).stdout.toString()).version;
const VERSION = JSON.parse(spawnSync('curl',
['-s', 'https://api.github.com/repos/VueTorrent/VueTorrent/releases/latest'],
{ shell: true }).stdout.toString()).tag_name.replace('v', '');
const URL = `https://github.com/VueTorrent/VueTorrent/releases/download/v${VERSION}/vuetorrent.zip`;
const HASH = parseFetchurl(URL);
const fileText = genVueText(VERSION, HASH, URL);
writeFileSync(FILE, fileText);
return OLD_VERSION !== VERSION ? `Vuetorrent: ${OLD_VERSION} -> ${VERSION}` : '';
};
const getAttrVersion = (attr: string): string => spawnSync('nix',
['eval', '--raw', `${FLAKE}#${attr}.version`],
{ shell: true }).stdout.toString();
export const runNixUpdate = (
attr: string,
scope?: string,
scopeAttr?: string,
): { stdout: string, stderr: string } => {
const getJsonArray = (jsonObj: string) => Array(JSON.parse(jsonObj))[0].slice(1).join(' ');
const realAttr = scope ? `${attr}.x86_64-linux.${scope}.${scopeAttr}` : attr;
const OLD_VERSION = getAttrVersion(realAttr);
const execOptions = spawnSync(
`nix eval --json ${FLAKE}#${realAttr}.updateScript`,
[],
{ shell: true, cwd: FLAKE },
);
const options = execOptions.status === 0 ?
execOptions.stdout.toString().startsWith('[') ?
getJsonArray(execOptions.stdout.toString()) :
'-u' :
'';
const execution = spawnSync(
`nix-update --flake ${realAttr} ${options} --write-commit-message >(head -n 1 -) > /dev/null`,
[],
{ shell: true, cwd: FLAKE },
);
const NEW_VERSION = getAttrVersion(realAttr);
return {
stdout: OLD_VERSION !== NEW_VERSION ?
scope ?
execution.stdout.toString().replaceAll(`${attr}.x86_64-linux.${scope}.`, '') :
execution.stdout.toString() :
'',
stderr: execution.stderr.toString(),
};
};
const genPluginsText = (
plugins: Record<string, { url: string, version: string }>,
) => `# This file was autogenerated. DO NOT EDIT!
{
plugins = {
${Object.entries(plugins)
.map(([key, value]) => `
${key} = {
url = "${value.url}";
version = "${value.version}";
};
`)
.join('')}
};
hash = "";
}
`;
export const updateCaddyPlugins = () => {
let updates = '';
const dir = `${FLAKE}/configurations/cluster/modules/caddy`;
// Setup workspace
spawnSync(
[
'rm -rf /tmp/update-caddy',
'mkdir -p /tmp/update-caddy',
'cd /tmp/update-caddy || exit 1',
'go mod init temp',
].join('; '),
[],
{ shell: true, cwd: '/tmp' },
);
const plugins = JSON.parse(spawnSync('nix',
['eval', '-f', `${dir}/plugins.nix`, '--json'],
{ shell: true }).stdout.toString()).plugins as Record<string, { url: string, version: string }>;
// Get most recent versions of plugins
Object.entries(plugins).forEach(([key, value]) => {
const NEW_VERSION = spawnSync([
'go mod init temp > /dev/null',
`go get ${value.url} > /dev/null`,
`grep '${value.url}' go.mod`,
].join('; '), [], { shell: true, cwd: '/tmp/update-caddy' })
.stdout
.toString()
.trim()
.replace(' // indirect', '')
.split(' ')[1];
if (plugins[key].version !== NEW_VERSION) {
updates += `${key}: ${plugins[key].version} -> ${NEW_VERSION}`;
plugins[key].version = NEW_VERSION;
}
});
writeFileSync(`${dir}/plugins.nix`, genPluginsText(plugins));
// Get new hash
const caddyPkgAttr = 'nixosConfigurations.thingone.config.services.caddy.package';
const NEW_HASH = spawnSync(
`nix build "$FLAKE#${caddyPkgAttr}" |& sed -n 's/.*got: *//p'`,
[],
{ shell: true },
).stdout.toString().trim();
replaceInFile(/hash = ".*";/, `hash = "${NEW_HASH}";`, `${dir}/plugins.nix`);
return updates;
};

View file

@ -1,103 +0,0 @@
import { readPackageJSON, writePackageJSON } from 'pkg-types';
import { accessSync, constants, existsSync } from 'node:fs';
import { spawnSync } from 'node:child_process';
import { replaceInFile, npmRun } from './lib';
/* Constants */
const FLAKE = process.env.FLAKE as string;
const updatePackageJson = async(workspaceDir: string, updates: object) => {
const currentPackageJson = await readPackageJSON(`${workspaceDir}/package.json`);
const outdated = JSON.parse(npmRun(['outdated', '--json'], workspaceDir));
const updateDeps = (deps: string) => {
Object.keys(currentPackageJson[deps]).forEach((dep) => {
const versions = outdated[dep];
const current = versions?.wanted || versions?.current;
if (!current) {
return;
}
if (current !== versions.latest) {
updates[dep] = `${current} -> ${versions.latest}`;
}
currentPackageJson[deps][dep] = versions.latest;
});
};
if (currentPackageJson.dependencies) {
updateDeps('dependencies');
}
if (currentPackageJson.devDependencies) {
updateDeps('devDependencies');
}
await writePackageJSON(`${workspaceDir}/package.json`, currentPackageJson);
};
const prefetchNpmDeps = (workspaceDir: string): string => {
npmRun(['update', '--package-lock-only'], workspaceDir);
return spawnSync(
'prefetch-npm-deps',
[`${workspaceDir}/package-lock.json`],
).stdout.toString().replace('\n', '');
};
export default async() => {
console.log('Updating node modules');
const updates = {};
const packages = spawnSync('find', [FLAKE, '-name', 'package.json']).stdout.toString().split('\n')
.filter((f) => f !== '')
.filter((f) => ![
'.direnv',
'node_modules',
'results',
].some((dirName) => f.includes(dirName)));
for (const path of packages) {
console.log(path);
try {
accessSync(path, constants.R_OK | constants.W_OK);
const parentPath = path.replace('/package.json', '');
await updatePackageJson(parentPath, updates);
if (existsSync(`${parentPath}/default.nix`)) {
const hash = prefetchNpmDeps(parentPath);
replaceInFile(
/npmDepsHash = ".*";/,
`npmDepsHash = "${hash}";`,
`${parentPath}/default.nix`,
);
}
// Make sure we update the apps' config package-lock.json
if (parentPath.includes('apps/config')) {
npmRun(['i'], parentPath);
}
}
catch (e) {
console.warn(`Could not write to ${path}`);
console.warn(e);
}
}
return Object.entries(updates)
.map(([key, dep]) => `${key}: ${dep}`)
.join('\n');
};

View file

@ -1,10 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../config/tsconfig.base.json",
"includes": [
"*.ts",
"**/*.ts",
"*.js",
"**/*.js"
]
}

129
conf/pkgs.log Normal file
View file

@ -0,0 +1,129 @@
acpi
alacritty
asp
bat
blueman
bluez
bluez-plugins
bluez-tools
bluez-utils
brightnessctl
cliphist
cpio
cups
discord
doctest
dolphin
dosfstools
exfatprogs
f2fs-tools
ffmpeg-compat-57
ffmpegthumbs
firefox
flatery-icon-theme-git
fwupd
galaxybudsclient-bin
gimp
git-lfs
gnome-bluetooth-3.0
gnome-calculator
gnome-keyring
gnome-themes-extra
gparted
grim
grub-customizer
gtklock
gtklock-playerctl-module
gtklock-powerbar-module
gtklock-userinfo-module
hplip
hyprpaper-git
iio-sensor-proxy-git
jdk-temurin
kde-cli-tools
kdegraphics-thumbnailers
kimageformats
kio-admin
kvantum
libinput-gestures-git
libreoffice-fresh
light
lostfiles
nano
neofetch
neovim-git
network-manager-applet
nextcloud-client
nilfs-utils
nm-connection-editor
nwg-look-bin
otf-font-awesome
pavucontrol
photoqt
pkgfile
pokemon-colorscripts-git
polkit-kde-agent
progress
python-evdev
python-libevdev
python-pyclip
python-pyqt5
python-pyqt5-3d
python-pyqt5-chart
python-pyqt5-datavisualization
python-pyqt5-networkauth
python-pyqt5-purchasing
python-pyqt5-webengine
python-pyqt6
python-pyqt6-3d
python-pyqt6-charts
python-pyqt6-datavisualization
python-pyqt6-networkauth
python-pyqt6-webengine
python-uinput
qt5-charts
qt5-imageformats
qt5ct
reiserfsprogs
ripgrep
rofi-lbonn-wayland-only-git
rustup
sddm-git
seahorse
slurp
spicetify-cli-git
spicetify-themes-git
spotify-snapstore
spotifywm-git
squeekboard-git
swappy-git
swayidle
swaync-git
swayosd-git
tablet-mode
tlp
ttf-font-awesome
ttf-go-nerd
ttf-jetbrains-mono
ttf-jetbrains-mono-nerd
ttf-meslo-nerd-font-powerlevel10k
ttf-ms-win11-auto
ttf-nerd-fonts-symbols
ttf-nerd-fonts-symbols-common
ttf-space-mono-nerd
ttf-ubuntu-font-family
ttf-ubuntu-nerd
tutanota-desktop-bin
waybar-hyprland-git
waydroid-git
wev
wine-staging
winetricks
wl-clip-persist-git
wl-color-picker
xclip
xdg-desktop-portal-hyprland-git
xdg-utils
xorg-xwayland
zathura-pdf-mupdf
zenity

1
conf/toinstall.sh Executable file
View file

@ -0,0 +1 @@
yay -Sy acpi alacritty asp bat blueman bluez bluez-plugins bluez-tools bluez-utils brightnessctl cliphist cpio cups discord doctest dolphin dosfstools exfatprogs f2fs-tools ffmpeg-compat-57 ffmpegthumbs firefox flatery-icon-theme-git fwupd galaxybudsclient-bin gimp git-lfs gnome-bluetooth-3.0 gnome-calculator gnome-keyring gnome-themes-extra gparted grim grub-customizer gtklock gtklock-playerctl-module gtklock-powerbar-module gtklock-userinfo-module hplip hyprpaper-git iio-sensor-proxy-git jdk-temurin kde-cli-tools kdegraphics-thumbnailers kimageformats kio-admin kvantum libinput-gestures-git libreoffice-fresh light lostfiles nano neofetch neovim-git network-manager-applet nextcloud-client nilfs-utils nm-connection-editor nwg-look-bin otf-font-awesome pavucontrol photoqt pkgfile pokemon-colorscripts-git polkit-kde-agent progress python-evdev python-libevdev python-pyclip python-pyqt5 python-pyqt5-3d python-pyqt5-chart python-pyqt5-datavisualization python-pyqt5-networkauth python-pyqt5-purchasing python-pyqt5-webengine python-pyqt6 python-pyqt6-3d python-pyqt6-charts python-pyqt6-datavisualization python-pyqt6-networkauth python-pyqt6-webengine python-uinput qt5-charts qt5-imageformats qt5ct reiserfsprogs ripgrep rofi-lbonn-wayland-only-git rustup sddm-git seahorse slurp spicetify-cli-git spicetify-themes-git spotify-snapstore spotifywm-git squeekboard-git swappy-git swayidle swaync-git swayosd-git tablet-mode tlp ttf-font-awesome ttf-go-nerd ttf-jetbrains-mono ttf-jetbrains-mono-nerd ttf-meslo-nerd-font-powerlevel10k ttf-ms-win11-auto ttf-nerd-fonts-symbols ttf-nerd-fonts-symbols-common ttf-space-mono-nerd ttf-ubuntu-font-family ttf-ubuntu-nerd tutanota-desktop-bin waybar-hyprland-git waydroid-git wev wine-staging winetricks wl-clip-persist-git wl-color-picker xclip xdg-desktop-portal-hyprland-git xdg-utils xorg-xwayland zathura-pdf-mupdf zenity

View file

@ -1,19 +0,0 @@
# NixosConfigurations
This directory contains every device's main configuration file, their `hardware-configuration.nix` and some custom modules
unique to them.
## List of my devices
| Name | Model / Specs | Description |
| --------- | ------------- | ------------------------------------------------------------------------------------------------ |
| `android` | OnePlus 9 Pro | [Nix-On-Droid](https://github.com/nix-community/nix-on-droid) configuration for my OnePlus 9 Pro |
| `bbsteamie` | 512GB OLED | My wife's SteamDeck that has a pink case (it took a lot of convincing for this) |
| `binto` | NVIDIA 3070 with Ryzen 7 3700X | Desktop PC with a multi-monitor setup |
| `homie` | Lenovo Thinkcentre M910q | Mini PC that serves as a Home-assistant server |
| `live-image` | USB key | Basic configuration that serves as my custom ISO target |
| `nos` | NVIDIA 3060 with i5-3600 | Custom built NAS and seedbox for Linux ISOs ;) |
| `servivi` | Headless Ryzen 5 3600 | Gaming PC in a previous life, it is now used as a build farm and hosts game servers |
| `thingone` | Lenovo ThinkCentre M900 | Mini PC that makes use of [NixOS-pcsd](https://github.com/matt1432/nixos-pcsd) to form a cluster with its twin. Files located in `cluster` |
| `thingtwo` | Lenovo ThinkCentre M900 | Mini PC that makes use of [NixOS-pcsd](https://github.com/matt1432/nixos-pcsd) to form a cluster with its twin. Files located in `cluster` |
| `wim` | ThinkPad L13 Yoga Gen 3 (Ryzen 7 PRO 5875U) | 2-1 Lenovo Laptop that I use for university |

View file

@ -1,56 +0,0 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib) attrValues concatStringsSep;
in {
imports = [./nix-on-droid.nix];
environment.variables.FLAKE = "/data/data/com.termux.nix/files/home/.nix";
terminal.font = "${
pkgs.nerd-fonts.jetbrains-mono
}/share/fonts/truetype/NerdFonts/JetBrainsMono/JetBrainsMonoNerdFontMono-Regular.ttf";
environment.packages = [
(pkgs.writeShellApplication {
name = "switch";
runtimeInputs = attrValues {
inherit
(pkgs)
coreutils
nix-output-monitor
nvd
;
};
text = ''
oldProfile=$(realpath /nix/var/nix/profiles/per-user/nix-on-droid/profile)
nix-on-droid ${concatStringsSep " " [
"switch"
"--flake ${config.environment.variables.FLAKE}"
"--builders ssh-ng://matt@100.64.0.7"
''"$@"''
"|&"
"nom"
]} &&
nvd diff "$oldProfile" "$(realpath /nix/var/nix/profiles/per-user/nix-on-droid/profile)"
'';
})
];
environment.etcBackupExtension = ".bak";
environment.motd = null;
home-manager.backupFileExtension = "hm-bak";
# Set your time zone.
time.timeZone = "America/Montreal";
# No touchy
system.stateVersion = "23.05";
}

View file

@ -1,97 +0,0 @@
{
config,
self,
...
}: {
imports = [
self.nixosModules.base-droid
{
roles.base = {
enable = true;
user = "nix-on-droid";
};
}
self.nixosModules.tmux
{programs.tmux.enableCustomConf = true;}
];
nix = {
# Edit nix.conf
extraOptions = ''
experimental-features = nix-command flakes
keep-outputs = true
keep-derivations = true
warn-dirty = false
'';
substituters = [
# Nix-community
"https://nix-community.cachix.org"
# Personal cache
"https://cache.nelim.org"
];
trustedPublicKeys = [
# Nix-community
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
# Personal cache
"cache.nelim.org:JmFqkUdH11EA9EZOFAGVHuRYp7EbsdJDHvTQzG2pPyY="
];
};
# Global hm settings
home-manager.config = {
imports = [
self.homeManagerModules.neovim
{
programs.neovim = {
enable = true;
user = "nix-on-droid";
ideConfig = {
enableJava = false;
enableNix = false;
enablePython = false;
};
};
}
self.homeManagerModules.shell
{programs.bash.enable = true;}
{
programs.bash.sessionVariables = {
FLAKE = config.environment.variables.FLAKE;
};
programs.bash.shellAliases = {
# Make ping work on nix-on-droid
# https://github.com/nix-community/nix-on-droid/issues/185#issuecomment-1659294700
ping = "/android/system/bin/linker64 /android/system/bin/ping";
# SSH
# Desktop
pc = "ssh -t matt@100.64.0.6 'tmux -2u new -At phone'";
# NAS
nos = "ssh -t matt@100.64.0.4 'tmux -2u new -At phone'";
# Experimenting server
servivi = "ssh -t matt@100.64.0.7 'tmux -2u new -At phone'";
# Home-assistant
homie = "ssh -t matt@100.64.0.10 'tmux -2u new -At phone'";
# Cluster nodes
thingone = "ssh -t matt@100.64.0.8 'tmux -2u new -At phone'";
thingtwo = "ssh -t matt@100.64.0.9 'tmux -2u new -At phone'";
};
}
];
home.stateVersion = "23.05";
};
}

View file

@ -1,80 +0,0 @@
{
mainUser,
self,
...
}: {
# ------------------------------------------------
# Imports
# ------------------------------------------------
imports = [
./hardware-configuration.nix
./modules
self.nixosModules.base
self.nixosModules.kmscon
self.nixosModules.meta
self.nixosModules.plymouth
self.nixosModules.server
];
# State Version: DO NOT CHANGE
system.stateVersion = "24.11";
# ------------------------------------------------
# User Settings
# ------------------------------------------------
users.users.${mainUser} = {
isNormalUser = true;
extraGroups = [
"wheel"
"adm"
];
};
networking = {
hostName = "bbsteamie";
networkmanager.enable = true;
};
time.timeZone = "America/Montreal";
# ------------------------------------------------
# `Self` Modules configuration
# ------------------------------------------------
meta = {
roleDescription = "My wife's SteamDeck that has a pink case (it took a lot of convincing for this)";
hardwareDescription = "512GB OLED";
};
roles.base = {
enable = true;
user = mainUser;
};
roles.server = {
enable = true;
user = mainUser;
sshd.enable = true;
};
boot.plymouth = {
enable = true;
theme = "bgrt";
};
services.kmscon.enable = true;
home-manager.users.${mainUser} = {
imports = [
self.homeManagerModules.shell
];
programs = {
bash = {
enable = true;
promptMainColor = "pink";
};
};
};
}

View file

@ -1,77 +0,0 @@
{
config,
jovian,
modulesPath,
pkgs,
...
}: {
nixpkgs.hostPlatform = "x86_64-linux";
nixpkgs.overlays = [
jovian.overlays.default
# Overlays for gamescope don't get applied properly for some reason
(final: prev: {
inherit
(jovian.legacyPackages.${pkgs.system})
gamescope
gamescope-session
gamescope-wsi
pkgsi686Linux
;
})
];
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
jovian.nixosModules.default
];
jovian = {
steamos.useSteamOSConfig = true;
devices.steamdeck = {
enable = true;
enableGyroDsuService = true;
};
hardware.has.amd.gpu = true;
};
boot = {
kernelModules = ["kvm-amd"];
initrd.availableKernelModules = ["nvme" "xhci_pci" "usbhid" "sdhci_pci"];
loader = {
efi.canTouchEfiVariables = true;
systemd-boot = {
enable = true;
configurationLimit = 30;
};
};
};
virtualisation.waydroid.enable = true;
fileSystems = {
"/" = {
device = "/dev/disk/by-label/NIXROOT";
fsType = "ext4";
};
"/boot" = {
device = "/dev/disk/by-label/NIXBOOT";
fsType = "vfat";
options = ["fmask=0022" "dmask=0022"];
};
};
swapDevices = [
{
device = "/.swapfile";
size = 16 * 1024; # 16GB
}
];
hardware.cpu.amd.updateMicrocode = config.hardware.enableRedistributableFirmware;
}

View file

@ -1,5 +0,0 @@
{...}: {
imports = [
./desktop
];
}

View file

@ -1,40 +0,0 @@
{pkgs, ...}: let
defaultSession = "plasma";
in {
imports = [
(import ./session-switching.nix defaultSession)
(import ./steam.nix defaultSession)
];
services.desktopManager.plasma6.enable = true;
programs = {
kdeconnect.enable = true;
xwayland.enable = true;
};
# Flatpak support for Discover
services.flatpak.enable = true;
services.packagekit.enable = true;
# Wayland env vars
environment.variables = {
NIXOS_OZONE_WL = "1";
ELECTRON_OZONE_PLATFORM_HINT = "auto";
};
environment.systemPackages = builtins.attrValues {
inherit
(pkgs)
firefox
wl-clipboard
xclip
;
inherit
(pkgs.kdePackages)
discover
krfb
;
};
}

View file

@ -1,81 +0,0 @@
# How to install Palia Map and Overwolf on Linux
Dependencies:
- latest GE-Proton: https://github.com/GloriousEggroll/proton-ge-custom
- protontricks: https://github.com/Matoking/protontricks
- protonhax: https://github.com/jcnils/protonhax
## First Step: Install and run Palia at least once
## Second Step: Setup Palia WINEPREFIX with latest GE-Proton
1. Delete prefix at /home/"$USER"/.steam/steam/steamapps/compatdata/2707930/pfx
```bash
rm -r /home/"$USER"/.steam/steam/steamapps/compatdata/2707930/pfx
```
2. Launch Palia with GE-Proton by going to game properties -> Compatibility -> Force the use ... -> Select GE-Proton...
3. Install dotnet48 and other Windows deps to allow for Overwolf installation
```bash
# Force proton version of protontricks
export PROTON_VERSION="GE-Proton9-10"
protontricks 2707930 dotnet48
# If VC is needed
protontricks 2707930 vcrun2010
protontricks 2707930 vcrun2012
protontricks 2707930 vcrun2013
```
## Third Step: Install Overwolf
1. Get this older version that worked for me here: https://overwolf.en.uptodown.com/windows/download/4714215
2. Install it with protontricks. Follow the GUI installer as if you were on Windows
```bash
export PROTON_VERSION="GE-Proton9-10"
protontricks-launch --appid 2707930 Downloads/overwolf-0-195-0-18.exe
```
## Fourth Step: Install Palia Map
1. Get the installer from here: https://www.overwolf.com/app/Leon_Machens-Palia_Map
2. Install it with protontricks.
```bash
export PROTON_VERSION="GE-Proton9-10"
protontricks-launch --appid 2707930 Downloads/Palia\ Map\ -\ Installer.exe
```
3. An error should popup saying `Installation failed` or something along those lines.
Close it and wait. You should see the Overwolf overlay on the left side of your screen
with the Palia Map icon saying `Installing` and then when it's done: `Palia Map`.
If nothing happens, try rebooting your PC and retrying the above shell commands until it works.
## Final Step: Setting it up in Steam
1. Add this line to Palia launch options
```bash
protonhax init %command%
```
2. Add random non-steam game to your library and then edit its properties:
Change the name to `Palia Map` or anything you like
Change the target to this command:
```bash
protonhax run 2707930 "/home/$USER/.local/share/Steam/steamapps/compatdata/2707930/pfx/drive_c/users/steamuser/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Overwolf/Palia Map.lnk"
```

View file

@ -1,131 +0,0 @@
defaultSession: {
config,
lib,
mainUser,
pkgs,
...
}: {
config = let
inherit (lib) findFirst getExe mkForce;
restartNetwork = getExe (pkgs.writeShellApplication {
name = "restart-network";
runtimeInputs = with pkgs; [systemd];
text = "systemctl restart NetworkManager";
});
switch-session = pkgs.writeShellApplication {
name = "switch-session";
text = ''
mkdir -p /etc/sddm.conf.d
cat <<EOF | tee /etc/sddm.conf.d/autologin.conf
[Autologin]
User=${mainUser}
Session=$1
Relogin=true
EOF
'';
};
gaming-mode = pkgs.writeShellScriptBin "gaming-mode" ''
sudo ${pkgs.systemd}/bin/systemctl start to-gaming-mode.service
'';
in {
services.displayManager.sddm = {
enable = true;
autoLogin.relogin = true;
wayland = {
enable = true;
compositorCommand = "kwin";
};
};
# Sets the default session at launch
systemd.services."set-session" = {
wantedBy = ["multi-user.target"];
before = ["display-manager.service"];
path = [switch-session];
script = ''
switch-session "${defaultSession}"
'';
};
# Allows switching to gaming mode
systemd.services."to-gaming-mode" = {
wantedBy = mkForce [];
path = [switch-session];
script = ''
switch-session "gamescope-wayland"
systemctl restart display-manager
sleep 10
switch-session "${defaultSession}"
'';
};
security.sudo.extraRules = [
{
users = [mainUser];
groups = [100];
commands = [
# Make it so we don't need root to switch to gaming mode
{
command = "${pkgs.systemd}/bin/systemctl start to-gaming-mode.service";
options = ["SETENV" "NOPASSWD"];
}
# Make it so we don't need root to restart the network on launch
{
command = restartNetwork;
options = ["SETENV" "NOPASSWD"];
}
];
}
];
home-manager.users.${mainUser} = {
# Add desktop entry to make it GUI friendly
xdg.desktopEntries."Gaming Mode" = {
name = "Gaming Mode";
exec = getExe gaming-mode;
icon = "steam";
terminal = false;
type = "Application";
};
home.file."Desktop/Gaming Mode.desktop".source =
(
findFirst
(x: x.meta.name == "Gaming Mode.desktop") {}
config.home-manager.users.mariah.home.packages
)
+ "/share/applications/Gaming Mode.desktop";
# Fix remote control prompt showing up everytime
xdg.configFile = let
mkAutostart = name: exe: {
"autostart/${name}.desktop".text = "[Desktop Entry]\nType=Application\nExec=${exe}";
};
in (
(mkAutostart "restart-network" "sudo ${restartNetwork}")
// (mkAutostart "steam" "steam -silent %U")
// (mkAutostart "krfb" "krfb --nodialog %c")
// (mkAutostart "kde-authorize-steam" (getExe (pkgs.writeShellApplication {
name = "kde-authorize-steam";
text = ''
flatpak permission-set kde-authorized remote-desktop org.kde.krdpserver yes
flatpak permission-set kde-authorized remote-desktop "" yes
'';
})))
);
};
};
# For accurate stack trace
_file = ./session-switching.nix;
}

View file

@ -1,87 +0,0 @@
defaultSession: {
config,
lib,
mainUser,
pkgs,
self,
...
}: let
inherit (lib) attrValues makeSearchPathOutput;
in {
config = {
# Normal Steam Stuff
programs.steam = {
enable = true;
protontricks.enable = true;
remotePlay.openFirewall = true;
extraCompatPackages = [
self.packages.${pkgs.system}.proton-ge-latest
];
# https://github.com/NixOS/nixpkgs/issues/25444#issuecomment-1977416787
extraPackages = with pkgs; [
kdePackages.breeze
];
};
# Jovian Steam settings
jovian.steam = {
# Steam > Settings > System > Enable Developer Mode
# Steam > Developer > CEF Remote Debugging
enable = true;
user = mainUser;
environment = {
STEAM_EXTRA_COMPAT_TOOLS_PATHS =
makeSearchPathOutput
"steamcompattool"
""
config.programs.steam.extraCompatPackages;
};
desktopSession = defaultSession;
};
# Decky settings
jovian.decky-loader = {
enable = true;
user = mainUser;
stateDir = "/home/${mainUser}/.local/share/decky"; # Keep scoped to user
# https://github.com/Jovian-Experiments/Jovian-NixOS/blob/1171169117f63f1de9ef2ea36efd8dcf377c6d5a/modules/decky-loader.nix#L80-L84
extraPackages = attrValues {
inherit
(pkgs)
curl
unzip
util-linux
gnugrep
readline
procps
pciutils
libpulseaudio
;
};
extraPythonPackages = p:
with p; [
click
];
};
# Misc Packages
environment.systemPackages = [
pkgs.steam-rom-manager
pkgs.r2modman
self.packages.${pkgs.system}.protonhax
# Ryujinx ACNH crashes on Vulkan
pkgs.ryujinx
];
};
# For accurate stack trace
_file = ./steam.nix;
}

View file

@ -1,103 +0,0 @@
{
mainUser,
self,
...
}: {
# ------------------------------------------------
# Imports
# ------------------------------------------------
imports = [
./hardware-configuration.nix
./modules
self.nixosModules.base
self.nixosModules.desktop
self.nixosModules.kmscon
self.nixosModules.meta
self.nixosModules.server
];
# State Version: DO NOT CHANGE
system.stateVersion = "23.11";
# ------------------------------------------------
# User Settings
# ------------------------------------------------
users.users.${mainUser} = {
isNormalUser = true;
extraGroups = [
"wheel"
"input"
"uinput"
"adm"
"video"
"libvirtd"
"adbusers"
];
};
programs.adb.enable = true;
networking = {
hostName = "binto";
networkmanager.enable = true;
firewall.enable = false;
};
time.timeZone = "America/Montreal";
# ------------------------------------------------
# `Self` Modules configuration
# ------------------------------------------------
meta = {
roleDescription = "Desktop PC with a multi-monitor setup";
hardwareDescription = "NVIDIA 3070 with Ryzen 7 3700X";
};
roles.base = {
enable = true;
user = mainUser;
};
roles.desktop = {
enable = true;
user = mainUser;
ags.enable = true;
mainMonitor = "desc:GIGA-BYTE TECHNOLOGY CO. LTD. G27QC 0x00000B1D";
fontSize = 12.5;
};
roles.server = {
enable = true;
user = mainUser;
tailscale.enable = true;
sshd.enable = true;
};
services.kmscon.enable = true;
home-manager.users.${mainUser} = {
imports = [
self.homeManagerModules.firefox
self.homeManagerModules.neovim
self.homeManagerModules.shell
];
programs = {
bash = {
enable = true;
promptMainColor = "purple";
};
firefox.enableCustomConf = true;
neovim = {
enable = true;
user = mainUser;
};
};
};
}

View file

@ -1,117 +0,0 @@
{
config,
modulesPath,
pkgs,
...
}: {
nixpkgs.hostPlatform = "x86_64-linux";
imports = [(modulesPath + "/installer/scan/not-detected.nix")];
boot = {
kernelPackages = pkgs.linuxPackages_zen;
kernelParams = [
"amd_pstate=active"
# Remove these if I use plymouth module
"quiet"
"splash"
"boot.shell_on_fail"
"i915.fastboot=1"
"loglevel=3"
"rd.systemd.show_status=false"
"rd.udev.log_level=3"
"udev.log_priority=3"
];
kernelModules = ["kvm-amd"];
# Zenpower for ryzen cpu monitoring
extraModulePackages = builtins.attrValues {
inherit
(config.boot.kernelPackages)
v4l2loopback
zenpower
;
};
blacklistedKernelModules = ["k10temp"];
supportedFilesystems = ["ntfs"];
consoleLogLevel = 0;
initrd = {
verbose = false;
systemd.enable = true;
availableKernelModules = ["nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod"];
};
loader = {
efi.canTouchEfiVariables = true;
timeout = 0;
systemd-boot = {
enable = true;
consoleMode = "max";
configurationLimit = 30;
};
};
};
fileSystems = {
"/" = {
device = "/dev/disk/by-label/NIXROOT";
fsType = "btrfs";
};
# sudo btrfs subvolume create /@swap
"/swap" = {
device = "/dev/disk/by-label/NIXROOT";
fsType = "btrfs";
# Idk why this is the subvol
options = ["subvol=@/@swap"];
};
"/boot" = {
device = "/dev/disk/by-label/NIXBOOT";
fsType = "vfat";
};
"/run/media/matt/Games" = {
device = "/dev/disk/by-uuid/da62f4ee-d4a6-4fdd-ab12-9c5e131c6f30";
fsType = "ext4";
};
};
swapDevices = [
{
device = "/swap/swapfile";
size = 16 * 1024;
}
];
zramSwap.enable = true;
hardware = {
cpu.amd.updateMicrocode = config.hardware.enableRedistributableFirmware;
uinput.enable = true;
};
virtualisation = {
libvirtd.enable = true;
spiceUSBRedirection.enable = true;
};
environment.systemPackages = builtins.attrValues {
inherit
(pkgs)
qemu
virtiofsd
;
};
nvidia = {
enable = true;
enableNvidiaSettings = true;
enableWayland = true;
enableCUDA = true;
};
}

View file

@ -1,6 +0,0 @@
{...}: {
imports = [
./gpu-replay
./nix-gaming
];
}

View file

@ -1,99 +0,0 @@
{
config,
lib,
mainUser,
pkgs,
self,
...
}: let
inherit (lib) concatStringsSep getExe removePrefix;
inherit (self.packages.${pkgs.system}) gpu-screen-recorder gsr-kms-server;
hyprPkgs = config.home-manager.users.${mainUser}.wayland.windowManager.hyprland.finalPackage;
cfgDesktop = config.roles.desktop;
in {
security.wrappers = {
gpu-screen-recorder = {
owner = "root";
group = "video";
capabilities = "cap_sys_nice+ep";
source = getExe gpu-screen-recorder;
};
gsr-kms-server = {
owner = "root";
group = "video";
capabilities = "cap_sys_admin+ep";
source = getExe gsr-kms-server;
};
};
home-manager.users.${mainUser} = {
home.packages = [
(pkgs.writeShellApplication {
name = "gpu-save-replay";
runtimeInputs = with pkgs; [procps];
text = ''
pkill --signal SIGUSR1 -f gpu-screen-recorder
'';
})
(pkgs.writeShellApplication {
name = "gsr-start";
runtimeInputs = [
pkgs.pulseaudio
pkgs.xorg.xrandr
hyprPkgs
];
text = ''
main="${removePrefix "desc:" cfgDesktop.mainMonitor}"
WINDOW=$(hyprctl -j monitors | jq '.[] |= (.description |= gsub(","; ""))' | jq -r ".[] | select(.description | test(\"$main\")) | .name")
# Fix fullscreen game resolution
xrandr --output "$WINDOW" --primary
gpu-screen-recorder ${concatStringsSep " " [
# Prints fps and damage info once per second.
"-v no"
# Replay buffer time in seconds.
"-r 1200"
# Organise replays in folders based on the current date.
"-df yes"
"-o /home/matt/Videos/Replay"
# Audio codec to use.
"-ac aac"
# Audio device or application to record from (pulse audio device).
"-a desktop/default_output"
"-a microphone/default_input"
# Window id to record, display (monitor name), "screen", "screen-direct", "focused" or "portal".
"-w \"$WINDOW\""
# Frame rate to record at.
"-f 60"
# Container format for output file.
"-c mkv"
# Video codec to use.
"-k hevc"
]}
'';
})
];
wayland.windowManager.hyprland.settings = {
bind = [",F8, exec, ags request 'save-replay'"];
};
};
}

View file

@ -1,38 +0,0 @@
{
nix-gaming,
pkgs,
self,
...
}: {
imports = [
nix-gaming.nixosModules.platformOptimizations
];
programs = {
steam = {
enable = true;
protontricks.enable = true;
remotePlay.openFirewall = true;
extraCompatPackages = [
self.packages.${pkgs.system}.proton-ge-latest
];
platformOptimizations.enable = true;
};
};
environment.systemPackages = [
(pkgs.lutris.override {
extraLibraries = pkgs: [
# List library dependencies here
];
extraPkgs = pkgs: [
# List extra packages available to lutris here
];
})
pkgs.r2modman
pkgs.ryujinx
];
}

View file

@ -1,106 +0,0 @@
deviceName: {
config,
mainUser,
self,
...
}: let
clusterIP = (builtins.head config.services.pcsd.virtualIps).ip;
in {
# ------------------------------------------------
# Imports
# ------------------------------------------------
imports = [
./hardware-configuration.nix
./modules
self.nixosModules.base
self.nixosModules.kmscon
self.nixosModules.meta
self.nixosModules.server
];
config = {
# State Version: DO NOT CHANGE
system.stateVersion = "24.05";
# ------------------------------------------------
# User Settings
# ------------------------------------------------
users.users.${mainUser} = {
isNormalUser = true;
extraGroups = [
"wheel"
"adm"
];
};
networking = {
hostName = deviceName;
resolvconf.enable = true;
nameservers = [
clusterIP
"1.0.0.1"
];
extraHosts = ''
10.0.0.244 thingone
10.0.0.159 thingtwo
'';
firewall.enable = false;
};
time.timeZone = "America/Montreal";
# ------------------------------------------------
# `Self` Modules configuration
# ------------------------------------------------
meta = {
roleDescription = ''
Mini PC that makes use of [NixOS-pcsd](https://github.com/matt1432/nixos-pcsd)
to form a cluster with its twin. Files located in `cluster`
'';
hardwareDescription = "Lenovo ThinkCentre M900";
};
roles.base = {
enable = true;
user = mainUser;
};
roles.server = {
enable = true;
user = mainUser;
tailscale.enable = true;
sshd.enable = true;
};
services.kmscon.enable = true;
home-manager.users.${mainUser} = {
imports = [
self.homeManagerModules.neovim
self.homeManagerModules.shell
];
programs = {
bash = {
enable = true;
promptMainColor =
if deviceName == "thingone"
then "green"
else if deviceName == "thingtwo"
then "red"
else "purple";
};
neovim = {
enable = true;
user = mainUser;
};
};
};
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -1,59 +0,0 @@
{
config,
modulesPath,
...
}: {
nixpkgs.hostPlatform = "x86_64-linux";
imports = [(modulesPath + "/installer/scan/not-detected.nix")];
boot = {
loader = {
efi.canTouchEfiVariables = true;
timeout = 2;
systemd-boot = {
enable = true;
consoleMode = "max";
configurationLimit = 30;
};
};
initrd.availableKernelModules = [
"xhci_pci"
"ahci"
"usbhid"
"usb_storage"
"sd_mod"
];
};
fileSystems = {
"/" = {
device = "/dev/disk/by-label/NIXROOT";
fsType = "btrfs";
};
# sudo btrfs subvolume create /@swap
"/swap" = {
device = "/dev/disk/by-label/NIXROOT";
fsType = "btrfs";
options = ["subvol=@swap"];
};
"/boot" = {
device = "/dev/disk/by-label/NIXBOOT";
fsType = "vfat";
};
};
swapDevices = [
{
device = "/swap/swapfile";
size = 16 * 1024;
}
];
zramSwap.enable = true;
hardware.cpu.intel.updateMicrocode = config.hardware.enableRedistributableFirmware;
}

View file

@ -1,24 +0,0 @@
{...}: {
services = {
blocky = {
enable = true;
settings = {
upstream = {
default = [
"127.0.0.1:5335"
"127.0.0.1:5335"
];
};
blocking = {
blackLists = {
ads = [
"https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"
];
};
};
};
};
};
}

View file

@ -1,177 +0,0 @@
{
config,
lib,
mainUser,
pkgs,
self,
...
}: let
inherit (lib) attrValues head removeAttrs;
inherit (config.sops) secrets;
inherit (config.networking) hostName;
in {
imports = [self.nixosModules.caddy-plus];
users.users.${mainUser}.extraGroups = ["caddy"];
boot.kernel.sysctl."net.ipv4.ip_nonlocal_bind" = 1;
systemd.services.caddy.serviceConfig = {
EnvironmentFile = secrets.caddy-cloudflare.path;
};
services.caddy = {
enable = true;
enableReload = false;
package = let
pluginsInfo = import ./plugins.nix;
in
pkgs.caddy.withPlugins {
plugins = map (x: "${x.url}@${x.version}") (attrValues pluginsInfo.plugins);
inherit (pluginsInfo) hash;
};
virtualHosts = let
clusterIP = (head config.services.pcsd.virtualIps).ip;
nosIP = "10.0.0.121";
serviviIP = "10.0.0.249";
homieIP = "100.64.0.10";
tlsConf = ''
tls {
dns cloudflare {$CLOUDFLARE_API_TOKEN}
resolvers 1.0.0.1
}
'';
mkPublicReverseProxy = subdomain: ip: extraConf:
{
hostName = "${subdomain}.nelim.org";
reverseProxy = ip;
listenAddresses = [clusterIP];
extraConfig = tlsConf + (extraConf.extraConfig or "");
}
// (removeAttrs extraConf ["extraConfig"]);
in {
# Public
"Home-Assistant" = mkPublicReverseProxy "homie" "${homieIP}:8123" {};
"Vaultwarden" = mkPublicReverseProxy "vault" "${nosIP}:8781" {};
"Hauk" = mkPublicReverseProxy "hauk" "${nosIP}:3003" {};
"Headscale" = mkPublicReverseProxy "headscale" "${clusterIP}:8085" {};
"SearXNG" = mkPublicReverseProxy "search" "${clusterIP}:8080" {};
"Jellyfin" = mkPublicReverseProxy "jelly" "${nosIP}:8096" {
subDirectories.jfa-go = {
subDirName = "accounts";
reverseProxy = "${nosIP}:8056";
};
};
"Jellyseer" = mkPublicReverseProxy "seerr" "${nosIP}:5055" {};
"Gameyfin" = mkPublicReverseProxy "games" "${nosIP}:8074" {};
"Forgejo" = mkPublicReverseProxy "git" "${nosIP}:3000" {};
"Nextcloud" = mkPublicReverseProxy "cloud" "${nosIP}:8042" {
extraConfig = ''
redir /.well-known/carddav /remote.php/dav 301
redir /.well-known/caldav /remote.php/dav 301
redir /.well-known/webfinger /index.php/.well-known/webfinger 301
redir /.well-known/nodeinfo /index.php/.well-known/nodeinfo 301
'';
};
"OnlyOffice" = mkPublicReverseProxy "office" "http://${nosIP}:8055" {};
"Immich" = mkPublicReverseProxy "photos" "${nosIP}:2283" {};
"ObsidianLiveSync" = mkPublicReverseProxy "livesync" "${nosIP}:5984" {};
"Binary Cache" = mkPublicReverseProxy "cache" "${serviviIP}:5000" {};
# Private
"nelim.org" = {
serverAliases = ["*.nelim.org"];
extraConfig = tlsConf;
listenAddresses = [
(
if hostName == "thingone"
then "100.64.0.8"
else "100.64.0.9"
)
];
subDomains = {
esphome.reverseProxy = "${homieIP}:6052";
pr-tracker.reverseProxy = "${serviviIP}:3000";
pcsd = {
extraConfig = ''
reverse_proxy https://${clusterIP}:2224 {
transport http {
tls_insecure_skip_verify
}
}
'';
};
# Resume builder
resume.reverseProxy = "${nosIP}:3060";
resauth.reverseProxy = "${nosIP}:3100";
# FreshRSS & Co
bridge.reverseProxy = "${nosIP}:3006";
drss.reverseProxy = "${nosIP}:3007";
freshrss = {
subDomainName = "rss";
reverseProxy = "${nosIP}:2800";
};
wgui.reverseProxy = "${nosIP}:51821";
lan = {
reverseProxy = "${nosIP}:3020";
extraConfig = ''
redir /index.html /
'';
subDirectories = {
bazarr.reverseProxy = "${nosIP}:6767";
jellystat.reverseProxy = "${nosIP}:3070";
prowlarr.reverseProxy = "${nosIP}:9696";
radarr.reverseProxy = "${nosIP}:7878";
sonarr.reverseProxy = "${nosIP}:8989";
qbittorent = {
subDirName = "qbt";
experimental = true;
reverseProxy = "${nosIP}:8080";
};
vaultwarden = {
subDirName = "vault";
experimental = true;
reverseProxy = "${nosIP}:8780";
};
};
};
# Top secret Business
joal.extraConfig = ''
route {
rewrite * /joal/ui{uri}
reverse_proxy * ${nosIP}:5656
}
'';
joalws.extraConfig = ''
route {
reverse_proxy ${nosIP}:5656
}
'';
};
};
};
};
}

View file

@ -1,11 +0,0 @@
# This file was autogenerated. DO NOT EDIT!
{
plugins = {
cloudflare = {
url = "github.com/caddy-dns/cloudflare";
version = "v0.0.0-20250214163716-188b4850c0f2";
};
};
hash = "sha256-izuQXvxIq3ycxcUuMErz7MbP9RwLkj+bhliK9H6Heqc=";
}

View file

@ -1,11 +0,0 @@
{...}: {
imports = [
./blocky
./caddy
./headscale
./nfs-client
./pcsd
./searxng
./unbound
];
}

View file

@ -1,70 +0,0 @@
{
config,
mainUser,
...
}: let
inherit (config.networking) hostName;
clusterIP = (builtins.head config.services.pcsd.virtualIps).ip;
in {
users.users.${mainUser}.extraGroups = ["headscale"];
services.headscale = {
enable = true;
settings = {
server_url = "https://headscale.nelim.org";
listen_addr = "${clusterIP}:8085";
prefixes = {
v4 = "100.64.0.0/10";
v6 = "fd7a:115c:a1e0::/48";
};
metrics_listen_addr = "127.0.0.1:9090";
grpc_listen_addr = "0.0.0.0:50443";
grpc_allow_insecure = false;
disable_check_updates = true;
ephemeral_node_inactivity_timeout = "30m";
unix_socket = "/run/headscale/headscale.sock";
unix_socket_permission = "0770";
database = {
type = "sqlite";
sqlite.path = "/var/lib/headscale/db.sqlite";
};
private_key_path = "/var/lib/headscale/private.key";
noise.private_key_path = "/var/lib/headscale/noise_private.key";
dns = let
caddyIp =
if hostName == "thingone"
then "100.64.0.8"
else "100.64.0.9";
in {
magic_dns = false;
override_local_dns = true;
nameservers.global = [caddyIp];
};
log = {
format = "text";
level = "info";
};
derp = {
auto_update_enable = true;
update_frequency = "24h";
server = {
enabled = true;
stun_listen_addr = "${clusterIP}:3479";
private_key_path = "/var/lib/headscale/derp_server_private.key";
region_id = 995;
region_code = "mon";
region_name = "montreal";
};
};
};
};
}

View file

@ -1,32 +0,0 @@
{pkgs, ...}: {
# NFS client setup
services.rpcbind.enable = true;
boot.supportedFilesystems = ["nfs"];
environment.systemPackages = builtins.attrValues {
inherit (pkgs) nfs-utils;
};
systemd.mounts = let
host = "10.0.0.249";
in [
{
type = "nfs";
mountConfig = {
Options = "noatime";
};
what = "${host}:/caddy";
where = "/var/lib/caddy";
requiredBy = ["caddy.service"];
}
{
type = "nfs";
mountConfig = {
Options = "noatime";
};
what = "${host}:/headscale";
where = "/var/lib/headscale";
requiredBy = ["headscale.service"];
}
];
}

View file

@ -1,73 +0,0 @@
{
config,
pcsd,
...
}: let
inherit (config.sops) secrets;
in {
imports = [pcsd.nixosModules.default];
services.pcsd = {
enable = true;
enableWebUI = true;
clusterName = "thingies";
corosyncKeyFile = secrets.corosync.path;
clusterUserPasswordFile = secrets.pcs-pass.path;
virtualIps = [
{
id = "caddy-vip";
ip = "10.0.0.130";
interface = "eno1";
group = "caddy-grp";
}
];
systemdResources = [
{
systemdName = "unbound";
enable = true;
group = "caddy-grp";
}
{
systemdName = "blocky";
enable = true;
group = "caddy-grp";
}
{
systemdName = "headscale";
enable = true;
group = "caddy-grp";
}
{
systemdName = "caddy";
enable = true;
group = "caddy-grp";
}
{
systemdName = "searx";
enable = true;
group = "caddy-grp";
}
];
nodes = [
{
name = "thingone";
nodeid = 1;
ring_addrs = ["10.0.0.244"];
}
{
name = "thingtwo";
nodeid = 2;
ring_addrs = ["10.0.0.159"];
}
];
};
}

View file

@ -1,73 +0,0 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib) head mapAttrsToList;
in {
services.searx = {
enable = true;
package = pkgs.searxng.overrideAttrs (o: {
postInstall = ''
${o.postInstall or ""}
# Replace logo
cp ${./logo.png} $out/${pkgs.python3.sitePackages}/searx/static/themes/simple/img/searxng.png
'';
});
environmentFile = config.sops.secrets.searxng.path;
settings = {
general = {
instance_name = "Search";
debug = false;
enable_metrics = false;
};
search = {
autocomplete = "google";
favicon_resolver = "google";
safe_search = 0;
default_lang = "en-CA";
};
ui = {
infinite_scroll = true;
query_in_title = true;
hotkeys = "vim";
};
server = {
port = 8080;
bind_address = (head config.services.pcsd.virtualIps).ip;
secret_key = "@SEARXNG_SECRET@";
public_instance = false;
};
engines = mapAttrsToList (name: value: {inherit name;} // value) {
"duckduckgo".disabled = false;
"duckduckgo images".disabled = false;
"gitlab".disabled = false;
"qwant".disabled = false;
"reddit".disabled = false;
"wikipedia" = {
engine = "wikipedia";
shortcut = "w";
base_url = "https://wikipedia.org/";
};
"github" = {
engine = "github";
shortcut = "gh";
};
};
};
};
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

View file

@ -1,94 +0,0 @@
{
config,
lib,
mainUser,
self,
...
}: let
inherit (self.lib) mergeAttrsList;
inherit (lib) mapAttrsToList remove;
inherit (config.networking) hostName;
serviviIP = "100.64.0.7";
caddyIp =
if hostName == "thingone"
then "100.64.0.8"
else "100.64.0.9";
in {
# https://github.com/MatthewVance/unbound-docker-rpi/issues/4#issuecomment-1001879602
boot.kernel.sysctl."net.core.rmem_max" = 1048576;
users.users.${mainUser}.extraGroups = ["unbound"];
services.unbound = {
enable = true;
enableRootTrustAnchor = true;
resolveLocalQueries = false;
settings = {
server = let
mkLocalEntry = domain: ip: {
local-zone = ["${domain} redirect"];
local-data = ["\"${domain} IN A ${ip}\""];
};
mkMinecraftEntry = domain: port: {
local-zone = ["${domain} transparent"];
local-data = [
"\"${domain} IN A ${serviviIP}\""
"\"_minecraft._tcp.${domain}. 180 IN SRV 0 0 ${toString port} ${domain}.\""
];
};
forceResolveEntry = domain: {
local-zone = ["${domain} always_transparent"];
};
publicApps = remove "nelim.org" (mapAttrsToList (n: v: v.hostName) config.services.caddy.virtualHosts);
in
mergeAttrsList (
[]
++ (map forceResolveEntry publicApps)
++ [
(mkMinecraftEntry "mc.nelim.org" 25569)
(mkMinecraftEntry "mc2.nelim.org" 25560)
(mkMinecraftEntry "cv.nelim.org" 25566)
(mkLocalEntry "nelim.org" caddyIp)
{
interface = ["127.0.0.1"];
port = 5335;
do-ip4 = true;
do-ip6 = false;
prefer-ip6 = false;
do-udp = true;
do-tcp = true;
# Performance
prefetch = true;
num-threads = 1;
private-address = [
"172.16.0.0/12"
"10.0.0.0/8"
"100.64.0.0/8"
"fd00::/8"
"fe80::/10"
];
# Default stuff
harden-glue = true;
harden-dnssec-stripped = true;
use-caps-for-id = false;
edns-buffer-size = 1232;
so-rcvbuf = "1m";
}
]
);
};
};
}

View file

@ -1,110 +0,0 @@
{
mainUser,
pkgs,
self,
...
}: {
# ------------------------------------------------
# Imports
# ------------------------------------------------
imports = [
./hardware-configuration.nix
./modules
self.nixosModules.base
self.nixosModules.docker
self.nixosModules.kmscon
self.nixosModules.meta
self.nixosModules.server
];
# State Version: DO NOT CHANGE
system.stateVersion = "24.11";
# ------------------------------------------------
# User Settings
# ------------------------------------------------
users.users.${mainUser} = {
isNormalUser = true;
extraGroups = [
"wheel"
"adm"
];
};
networking = {
hostName = "homie";
resolvconf.enable = true;
firewall.enable = false;
};
# FIXME: temporary fix while I figure out the issue with the Network Card?
systemd.services."temp-fix-nic" = {
wantedBy = ["multi-user.target"];
after = ["tailscaled.service"];
path = [pkgs.ripgrep];
script = ''
# Wait for boot to finish
sleep 60
echo "start listening to journalctl"
journalctl -fb | while read -r line; do
if echo "$line" | rg 'NIC Link is Up' &> /dev/null; then
echo "restarting tailscaled"
systemctl restart tailscaled.service
fi
done
'';
serviceConfig = {
User = "root";
AmbientCapabilities = "CAP_SYS_ADMIN CAP_SYSLOG";
};
};
time.timeZone = "America/Montreal";
# ------------------------------------------------
# `Self` Modules configuration
# ------------------------------------------------
meta = {
roleDescription = "Mini PC that serves as a Home-assistant server";
hardwareDescription = "Lenovo Thinkcentre M910q";
};
roles.base = {
enable = true;
user = mainUser;
};
roles.server = {
enable = true;
user = mainUser;
tailscale.enable = true;
sshd.enable = true;
};
roles.docker.enable = true;
services.kmscon.enable = true;
home-manager.users.${mainUser} = {
imports = [
self.homeManagerModules.neovim
self.homeManagerModules.shell
];
programs = {
bash = {
enable = true;
promptMainColor = "yellow";
};
neovim = {
enable = true;
user = mainUser;
};
};
};
}

View file

@ -1,61 +0,0 @@
{
config,
modulesPath,
...
}: {
nixpkgs.hostPlatform = "x86_64-linux";
imports = [(modulesPath + "/installer/scan/not-detected.nix")];
boot = {
loader = {
efi.canTouchEfiVariables = true;
timeout = 2;
systemd-boot = {
enable = true;
consoleMode = "max";
configurationLimit = 30;
};
};
initrd.availableKernelModules = [
"xhci_pci"
"ahci"
"nvme"
"usbhid"
"usb_storage"
"sd_mod"
];
};
fileSystems = {
"/" = {
device = "/dev/disk/by-label/NIXROOT";
fsType = "btrfs";
};
# sudo btrfs subvolume create /@swap
"/swap" = {
device = "/dev/disk/by-label/NIXROOT";
fsType = "btrfs";
options = ["subvol=@swap"];
};
"/boot" = {
device = "/dev/disk/by-label/NIXBOOT";
fsType = "vfat";
options = ["fmask=0022" "dmask=0022"];
};
};
swapDevices = [
{
device = "/swap/swapfile";
size = 16 * 1024;
}
];
zramSwap.enable = true;
hardware.cpu.intel.updateMicrocode = config.hardware.enableRedistributableFirmware;
}

View file

@ -1,103 +0,0 @@
# Unfortunately I had some hardware issues but this does work
{
lib,
pkgs,
...
}: let
inherit (lib) mkForce getExe;
connectControllers = getExe (pkgs.writeShellApplication {
name = "connectControllers";
runtimeInputs = with pkgs; [gnugrep usbutils];
text = ''
set +o errexit
for dev in /sys/bus/usb/devices/*; do
vendor="$(cat "$dev/idVendor" 2>/dev/null)"
prod="$(cat "$dev/idProduct" 2>/dev/null)"
if [[ "$vendor" != "" && "$prod" != "" ]]; then
if [[ "$(lsusb -d "$vendor:$prod" | grep "Microsoft Corp. Xbox Controller")" != "" ]]; then
echo 0 > "$dev/authorized"
echo 1 > "$dev/authorized"
fi
fi
done
'';
});
hyprConf = pkgs.writeText "greetd-hypr-config" ''
cursor {
inactive_timeout = 1
}
misc {
disable_hyprland_logo = true
disable_splash_rendering = true
}
decoration {
blur {
enabled = false
}
}
animations {
enabled = false
first_launch_animation = false
}
bind = SUPER, Q, exec, kitty
windowrule = fullscreen, ^(.*)$
exec-once = waydroid show-full-ui
exec-once = sleep 10; sudo ${connectControllers}
'';
user = "matt";
command = "Hyprland --config ${hyprConf}";
session = {inherit command user;};
in {
# Make it so we don't need root to connect controllers
security.sudo.extraRules = [
{
users = [user];
groups = [user];
commands = [
{
command = connectControllers;
options = ["SETENV" "NOPASSWD"];
}
];
}
];
# Stuff missing for complete declarative setup:
# - make the following declarative and also make the image declarative
# - Add this to /var/lib/waydroid/waydroid.cfg for controller support
# persist.waydroid.udev = true
# persist.waydroid.uevent = true
virtualisation.waydroid.enable = true;
users.users."greeter" = {
home = "/var/lib/greeter";
};
programs.hyprland.enable = true;
services = {
greetd = {
enable = true;
settings = {
default_session = session;
initial_session = session;
};
};
pipewire.enable = mkForce false;
};
environment.systemPackages = [pkgs.kitty];
}

View file

@ -1,6 +0,0 @@
{...}: {
imports = [
./home-assistant
./music
];
}

View file

@ -1,83 +0,0 @@
{
pkgs,
self,
wakewords-src,
...
}: {
imports = [
self.nixosModules.esphome-plus
self.nixosModules.wyoming-plus
];
services = {
home-assistant = {
package = pkgs.home-assistant.override {
packageOverrides = final: prev: {
# HassTimer has way too many collisions with my custom timer sentences
home-assistant-intents = prev.home-assistant-intents.overrideAttrs (o: {
nativeBuildInputs = o.nativeBuildInputs ++ [pkgs.findutils];
postPatch = ''
find ./. -name "*Timer*" -delete
find ./. -name "*Start*" -delete
'';
});
};
};
customComponents = builtins.attrValues {
inherit
(self.scopedPackages.${pkgs.system}.hass-components)
extended-ollama-conversation # url is without subdirectory
ha-fallback-conversation
tuya-local
;
};
extraComponents = [
"esphome"
"ollama"
"wyoming"
"scrape"
];
config = {
assist_pipeline = {};
conversation = {};
media_source = {};
};
};
wyoming = {
piper.servers."en" = {
enable = true;
uri = "tcp://127.0.0.1:10200";
# see https://github.com/rhasspy/rhasspy3/blob/master/programs/tts/piper/script/download.py
voice = "en_US-hfc_male-medium";
speaker = 0;
};
openwakeword = {
enable = true;
uri = "tcp://127.0.0.1:10400";
threshold = 0.55;
vadThreshold = 0.50;
customModelsDirectories = ["${wakewords-src}/en/yo_homie"];
preloadModels = ["yo_homie"];
extraArgs = ["--debug"];
};
};
esphome = {
enable = true;
address = "100.64.0.10";
port = 6052;
};
};
# In case tailscale is down
boot.kernel.sysctl."net.ipv4.ip_nonlocal_bind" = 1;
}

View file

@ -1,78 +0,0 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib) getExe;
turnOnUE = pkgs.writeShellApplication {
name = "turnOnUE";
runtimeInputs = [config.hardware.bluetooth.package];
text = ''
cmd=0x0003
bt_device_addr=88:C6:26:93:4B:77
# This is the MAC address on the first line of `bluetootctl show`
# without the `:` and with `01` added at the end
bt_controller_addr=E848B8C8200001
exec gatttool -b $bt_device_addr --char-write-req --handle=$cmd --value=$bt_controller_addr
'';
};
in {
environment.systemPackages = [turnOnUE];
services.home-assistant = {
extraComponents = [
"mpd"
# BT components
"ibeacon"
"led_ble"
"kegtron"
"xiaomi_ble"
];
# Turn On the speaker automatically when openwakeword is used
config = {
shell_command.turn_on_ue = getExe turnOnUE;
script.turn_on_ue = {
alias = "Music - TurnOnUE";
description = "Script for turning on the UE Boom 2 speaker.";
icon = "mdi:music";
mode = "single";
sequence = [
{
alias = "Run shell command";
service = "shell_command.turn_on_ue";
}
];
};
automation = [
{
alias = "Turn On UE";
mode = "single";
trigger = [
{
platform = "state";
entity_id = "wake_word.openwakeword";
}
];
condition = [];
action = [
{
action = "shell_command.turn_on_ue";
metadata = {};
data = {};
}
];
}
];
};
};
}

View file

@ -1,119 +0,0 @@
{
pkgs,
self,
...
}: {
imports = [
./assist.nix
./bluetooth.nix
./firmware.nix
./frontend.nix
./zigbee.nix
./netdaemon
./spotify
./timer
self.nixosModules.ha-plus
];
services.home-assistant = {
enable = true;
extraComponents = [
"androidtv"
"androidtv_remote"
"caldav"
"cast"
"holiday"
"isal"
"met"
"switchbot"
"upnp"
"yamaha_musiccast"
];
customComponents = builtins.attrValues {
inherit
(self.scopedPackages.${pkgs.system}.hass-components)
yamaha-soundbar
;
};
config = {
homeassistant = {
name = "Home";
unit_system = "metric";
currency = "CAD";
country = "CA";
time_zone = "America/Montreal";
external_url = "https://homie.nelim.org";
};
media_player = [
{
platform = "yamaha_soundbar";
host = "192.168.0.96";
name = "Living Room Speaker";
sources = {
HDMI = "TV";
};
}
];
# Proxy settings
http = {
server_host = "0.0.0.0";
trusted_proxies = ["100.64.0.8" "100.64.0.9"];
use_x_forwarded_for = true;
};
# `default_config` enables too much stuff. this is what I want from it
config = {};
dhcp = {};
history = {};
image_upload = {};
logbook = {};
mobile_app = {};
my = {};
sun = {};
zeroconf = {};
};
};
environment.systemPackages = [
(pkgs.writeShellApplication {
name = "yaml2nix";
runtimeInputs = with pkgs; [yj];
text = ''
input="$(yj < "$1")"
output="''${2:-""}"
nixCode="$(nix eval --expr "builtins.fromJSON '''$input'''" --impure | alejandra -q | sed 's/ = null;/ = {};/g')"
if [[ "$output" != "" ]]; then
echo "$nixCode" > "$output"
else
echo "$nixCode"
fi
'';
})
(pkgs.writeShellApplication {
name = "nix2yaml";
runtimeInputs = with pkgs; [remarshal];
text = ''
input="$1"
output="''${2:-""}"
yamlCode="$(nix eval --json --file "$input" | remarshal --if json --of yaml)"
if [[ "$output" != "" ]]; then
echo "$yamlCode" > "$output"
else
echo "$yamlCode"
fi
'';
})
];
}

View file

@ -1,26 +0,0 @@
# I use nix2yaml from ../default.nix to convert this to YAML and place it in the functions of extended_ollama_conversation
[
{
spec = {
name = "get_attributes";
description = "Get attributes of any home assistant entity";
parameters = {
type = "object";
properties = {
entity_id = {
type = "string";
description = "entity_id";
};
};
required = ["entity_id"];
};
};
function = {
type = "template";
value_template = "{{ states[entity_id] }}";
};
}
]

View file

@ -1,51 +0,0 @@
{%- set customize_glob_exposed_attributes = {
".*": {
"friendly_name": true,
"temperature": true,
"current_temperature": true,
"temperature_unit": true,
"brightness": true,
"humidity": true,
"unit_of_measurement": true,
"device_class": true,
"current_position": true,
"percentage": true,
"volume_level": true,
"media_title": true,
"media_artist": true,
"media_album_name": true,
},
} %}
{%- macro get_exposed_attributes(entity_id) -%}
{%- set ns = namespace(exposed_attributes = {}, result = {}) %}
{%- for pattern, attributes in customize_glob_exposed_attributes.items() -%}
{%- if entity_id | regex_match(pattern) -%}
{%- set ns.exposed_attributes = dict(ns.exposed_attributes, **attributes) -%}
{%- endif -%}
{%- endfor -%}
{%- for attribute_key, should_include in ns.exposed_attributes.items() -%}
{%- if should_include and state_attr(entity_id, attribute_key) != None -%}
{%- set temp = {attribute_key: state_attr(entity_id, attribute_key)} if should_include is boolean else {attribute_key: should_include} -%}
{%- set ns.result = dict(ns.result, **temp) -%}
{%- endif -%}
{%- endfor -%}
{%- set result = ns.result | to_json if ns.result!={} else None -%}
{{"'" + result + "'" if result != None else ''}}
{%- endmacro -%}
I want you to act as a personal assistant who is aware of my smart home.
You will truthfully answer in one sentence in everyday language.
Current Time: {{now()}}
Available Devices:
```csv
entity_id,name,state,aliases,attributes
{% for entity in exposed_entities -%}
{{ entity.entity_id }},{{ entity.name }},{{ entity.state }},{{entity.aliases | join('/')}},{{get_exposed_attributes(entity.entity_id)}}
{% endfor -%}
```
The current state of devices is provided in available devices.
Do not restate what user says.

View file

@ -1,387 +0,0 @@
{config, ...}: {
services.esphome = {
secretsFile = config.sops.secrets.esphome.path;
firmwareConfigs = {
# -------------------------------------------------------------
"AtomEcho" = {
# Device specific settings
api.encryption.key = "!secret api_key";
ota = [
{
platform = "esphome";
password = "!secret ota_pass";
}
];
wifi = {
ssid = "!secret wifi_ssid";
password = "!secret wifi_password";
manual_ip = {
static_ip = "192.168.0.92";
gateway = "192.168.0.1";
subnet = "255.255.255.0";
};
ap = {
ssid = "Esp1 Fallback Hotspot";
password = "!secret ap_fallback";
};
};
# Hardware Declaration
esphome = {
friendly_name = "M5Stack Atom Echo";
min_version = "2024.9.0";
name = "m5stack-atom-echo";
name_add_mac_suffix = true;
};
esp32 = {
board = "m5stack-atom";
framework = {
type = "esp-idf";
version = "4.4.8";
platform_version = "5.4.0";
};
};
esp_adf = {};
button = [
{
id = "button_safe_mode";
name = "Safe Mode Boot";
platform = "safe_mode";
}
{
id = "factory_reset_btn";
name = "Factory reset";
platform = "factory_reset";
}
];
microphone = [
{
adc_type = "external";
i2s_din_pin = "GPIO23";
id = "echo_microphone";
pdm = true;
platform = "i2s_audio";
}
];
speaker = [
{
dac_type = "external";
i2s_dout_pin = "GPIO21"; # "GPIO22"; turn off speaker
id = "echo_speaker";
channel = "mono";
platform = "i2s_audio";
}
];
i2s_audio = [
{
id = "i2s_audio_bus";
i2s_bclk_pin = "GPIO19";
i2s_lrclk_pin = "GPIO33";
}
];
light = [
{
id = "led";
name = "None";
entity_category = "config";
chipset = "SK6812";
pin = "GPIO27";
platform = "esp32_rmt_led_strip";
default_transition_length = "0s";
disabled_by_default = false;
num_leds = 1;
rgb_order = "grb";
rmt_channel = 0;
effects = [
{
pulse = {
name = "Slow Pulse";
max_brightness = "100%";
min_brightness = "50%";
transition_length = "250ms";
update_interval = "250ms";
};
}
{
pulse = {
name = "Fast Pulse";
max_brightness = "100%";
min_brightness = "50%";
transition_length = "100ms";
update_interval = "100ms";
};
}
];
}
];
# Home-assistant buttons
switch = [
{
id = "use_wake_word";
name = "Use wake word";
entity_category = "config";
optimistic = true;
platform = "template";
restore_mode = "RESTORE_DEFAULT_ON";
on_turn_on = [
{lambda = "id(va).set_use_wake_word(true);";}
{
"if" = {
condition.not = ["voice_assistant.is_running"];
"then" = ["voice_assistant.start_continuous"];
};
}
{"script.execute" = "reset_led";}
];
on_turn_off = [
"voice_assistant.stop"
{lambda = "id(va).set_use_wake_word(false);";}
{"script.execute" = "reset_led";}
];
}
{
id = "use_listen_light";
name = "Use listen light";
entity_category = "config";
optimistic = true;
platform = "template";
restore_mode = "RESTORE_DEFAULT_ON";
on_turn_on = [{"script.execute" = "reset_led";}];
on_turn_off = [{"script.execute" = "reset_led";}];
}
];
binary_sensor = [
{
id = "echo_button";
name = "Button";
entity_category = "diagnostic";
disabled_by_default = false;
platform = "gpio";
pin = {
inverted = true;
number = "GPIO39";
};
on_multi_click = [
{
timing = ["ON for at least 50ms" "OFF for at least 50ms"];
"then" = [
{
"if" = {
condition = {"switch.is_off" = "use_wake_word";};
"then" = [
{
"if" = {
condition = "voice_assistant.is_running";
"then" = [
{"voice_assistant.stop" = {};}
{"script.execute" = "reset_led";}
];
"else" = [{"voice_assistant.start" = {};}];
};
}
];
"else" = [
"voice_assistant.stop"
{delay = "1s";}
{"script.execute" = "reset_led";}
{"script.wait" = "reset_led";}
{"voice_assistant.start_continuous" = {};}
];
};
}
];
}
{
timing = ["ON for at least 10s"];
"then" = [{"button.press" = "factory_reset_btn";}];
}
];
}
];
# Misc
logger = {};
external_components = [
{
source = "github://pr#5230";
components = ["esp_adf"];
refresh = "0s";
}
];
# Configs
script = [
{
id = "reset_led";
"then" = [
{
"if" = {
condition = [
{"switch.is_on" = "use_wake_word";}
{"switch.is_on" = "use_listen_light";}
];
"then" = [
{
"light.turn_on" = {
id = "led";
brightness = "60%";
effect = "none";
red = "100%";
green = "89%";
blue = "71%";
};
}
];
"else" = [{"light.turn_off" = "led";}];
};
}
];
}
];
voice_assistant = {
id = "va";
speaker = "echo_speaker";
microphone = "echo_microphone";
auto_gain = "31dBFS";
noise_suppression_level = 2;
vad_threshold = 3;
volume_multiplier = 2;
on_listening = [
{
"light.turn_on" = {
id = "led";
effect = "Slow Pulse";
green = "0%";
red = "0%";
blue = "100%";
};
}
];
on_stt_vad_end = [
{
"light.turn_on" = {
id = "led";
effect = "Fast Pulse";
red = "0%";
green = "0%";
blue = "100%";
};
}
];
on_tts_start = [
{
"light.turn_on" = {
id = "led";
brightness = "100%";
effect = "none";
red = "0%";
green = "0%";
blue = "100%";
};
}
];
# Play audio from bluetooth speaker
on_tts_end = [
{
"homeassistant.service" = {
service = "media_player.play_media";
data = {
entity_id = "media_player.music_player_daemon";
media_content_id = "!lambda \"return x;\"";
media_content_type = "music";
announce = "\"true\"";
};
};
}
];
on_end = [
{delay = "100ms";}
{wait_until.not."speaker.is_playing" = {};}
{"script.execute" = "reset_led";}
];
on_error = [
{
"light.turn_on" = {
id = "led";
brightness = "100%";
effect = "none";
red = "100%";
green = "0%";
blue = "0%";
};
}
{delay = "1s";}
{"script.execute" = "reset_led";}
];
on_client_connected = [
{
"if" = {
condition = {"switch.is_on" = "use_wake_word";};
"then" = [
{"voice_assistant.start_continuous" = {};}
{"script.execute" = "reset_led";}
];
};
}
];
on_client_disconnected = [
{
"if" = {
condition = {"switch.is_on" = "use_wake_word";};
"then" = [
{"voice_assistant.stop" = {};}
{"light.turn_off" = "led";}
];
};
}
];
};
};
# -------------------------------------------------------------
};
};
}

View file

@ -1,384 +0,0 @@
{
caule-themes-src,
dracul-ha-src,
lib,
pkgs,
self,
...
}: let
inherit (lib) attrValues singleton;
inherit (pkgs.writers) writeYAML;
material-rounded-theme-src = self.scopedPackages.${pkgs.system}.lovelace-components.material-rounded-theme.src;
in {
services.home-assistant = {
configFiles = {
"themes/caule.yaml".source = "${caule-themes-src}/themes/caule-themes-pack-1.yaml";
"themes/dracul-ha.yaml".source = "${dracul-ha-src}/themes/dracul-ha.yaml";
"themes/material_rounded.yaml".source = "${material-rounded-theme-src}/themes/material_rounded.yaml";
"www/sidebar-config.yaml".source = writeYAML "sidebar" {
id = "my-sidebar";
order = [
# Top
{
item = "overview";
order = 1;
}
{
match = "href";
item = "calendar";
order = 2;
}
{
match = "href";
item = "todo";
order = 3;
}
# Bottom
{
bottom = true;
item = "esphome";
order = 5;
}
{
bottom = true;
item = "logbook";
order = 7;
}
{
bottom = true;
icon = "mdi:tools";
item = "developer tools";
name = "Developer tools";
order = 9;
}
{
bottom = true;
item = "settings";
order = 11;
}
# Hidden
{
hide = true;
item = "map";
}
{
hide = true;
item = "energy";
}
{
hide = true;
item = "history";
}
{
hide = true;
item = "media";
}
];
};
};
customComponents = attrValues {
inherit
(self.scopedPackages.${pkgs.system}.hass-components)
material-symbols
;
};
customLovelaceModules = attrValues {
inherit
(pkgs.home-assistant-custom-lovelace-modules)
card-mod
light-entity-card
universal-remote-card
;
inherit
(self.scopedPackages.${pkgs.system}.lovelace-components)
big-slider-card
custom-sidebar
material-rounded-theme
;
};
config.frontend = {
themes = "!include_dir_merge_named themes";
extra_module_url = map (p: "/local/nixos-lovelace-modules/${p}.js") [
"big-slider-card"
"card-mod"
"custom-sidebar-yaml"
"material-rounded-theme"
];
};
config.template = [
{
sensor = singleton {
name = "Material Rounded Base Color Matt";
unique_id = "material_rounded_base_color_matt";
state = ''{{ states("sensor.pixel_8_accent_color") }}'';
};
}
];
config.input_text = {
bathroom_light_brightness = {
name = "BathroomLightBrightness";
icon = "mdi:lightbulb";
# restricts to 0-100
pattern = "^(0|[1-9][0-9]?|100)$";
initial = "0";
max = 3;
};
bathroom_light_temperature = {
name = "BathroomLightTemperature";
pattern = "[0-9]*";
initial = "0";
};
};
lovelaceConfig = {
title = "Our House";
# I don't want multiple views
views = singleton {
path = "home";
title = "Home";
cards = [
{
type = "entities";
entities = [
"switch.smartplug1"
"switch.smartplug2"
"switch.smartplug3"
];
}
{
type = "entities";
entities = [
"timer.assist_timer1"
"timer.assist_timer2"
"timer.assist_timer3"
];
}
{
type = "custom:light-entity-card";
entity = "light.bathroomceiling";
shorten_cards = false;
consolidate_entities = false;
child_card = false;
hide_header = false;
show_header_icon = false;
header = "";
color_wheel = true;
persist_features = true;
brightness = true;
color_temp = true;
white_value = true;
color_picker = true;
speed = true;
intensity = false;
force_features = false;
show_slider_percent = true;
full_width_sliders = true;
brightness_icon = "weather-sunny";
white_icon = "file-word-box";
temperature_icon = "thermometer";
speed_icon = "speedometer";
intensity_icon = "transit-connection-horizontal";
}
{
type = "custom:android-tv-card";
visibility = singleton {
condition = "state";
entity = "remote.onn_4k_streaming_box";
state_not = ["unavailable" "unknown"];
};
media_player_id = "media_player.living_room_speaker";
keyboard_id = "remote.android_tv_192_168_0_106";
remote_id = "remote.onn_4k_streaming_box";
rows = [
"navigation_buttons"
[null "slider" null]
[null]
["jellyfin" "home" "back" "keyboard"]
[null]
];
custom_actions = [
{
name = "center";
type = "button";
icon = "mdi:checkbox-blank-circle";
styles = ''
:host {
--icon-color: rgb(94, 94, 94);
--size: 200px;
background: rgb(31, 31, 31);
border-radius: 200px;
margin: -70px;
padding: 70px;
}
'';
tap_action = {
action = "key";
key = "DPAD_CENTER";
};
}
{
name = "up";
type = "button";
icon = "mdi:chevron-up";
styles = ''
:host {
--icon-color: rgb(197, 199, 197);
z-index: 2;
top: 25px;
height: 90px;
width: 300px;
}
'';
hold_action = {action = "repeat";};
tap_action = {
action = "key";
key = "DPAD_UP";
};
}
{
name = "down";
type = "button";
icon = "mdi:chevron-down";
styles = ''
:host {
--icon-color: rgb(197, 199, 197);
z-index: 2;
bottom: 25px;
height: 90px;
width: 300px;
}
'';
hold_action = {action = "repeat";};
tap_action = {
action = "key";
key = "DPAD_DOWN";
};
}
{
name = "left";
type = "button";
icon = "mdi:chevron-left";
styles = ''
:host {
--icon-color: rgb(197, 199, 197);
z-index: 2;
left: 30px;
height: 170px;
width: 90px;
}
'';
hold_action = {action = "repeat";};
tap_action = {
action = "key";
key = "DPAD_LEFT";
};
}
{
name = "right";
type = "button";
icon = "mdi:chevron-right";
styles = ''
:host {
--icon-color: rgb(197, 199, 197);
z-index: 2;
right: 30px;
height: 170px;
width: 90px;
}
'';
hold_action = {action = "repeat";};
tap_action = {
action = "key";
key = "DPAD_RIGHT";
};
}
{
name = "slider";
type = "slider";
icon = "mdi:volume-high";
range = [0 1];
step = 0.01;
tap_action = {
action = "perform-action";
perform_action = "media_player.volume_set";
data = {
volume_level = "{{ value | float }}";
};
};
value_attribute = "volume_level";
}
];
styles = ''
#row-1 {
justify-content: center;
}
#row-2 {
justify-content: center;
}
#row-3 {
justify-content: center;
}
'';
}
];
};
};
config.lovelace.dashboards = {
esphome-dash = {
title = "ESPHome";
icon = "mdi:car-esp";
mode = "yaml";
show_in_sidebar = true;
require_admin = true;
filename = writeYAML "esphome.yaml" {
strategy = {
type = "iframe";
url = "https://esphome.nelim.org";
};
};
};
};
};
}

Some files were not shown because too many files have changed in this diff Show more