refactor: use genflake for better flake inputs handling
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-05-20 01:17:07 -04:00
parent 684b8a5c9e
commit 5f9dca81e1
12 changed files with 494 additions and 21 deletions

View file

@ -49,7 +49,10 @@ sudo ln -sf /home/matt/.nix /etc/nixos
### Flake Inputs ### Flake Inputs
I prefer using a more descriptive format for my inputs like so: To allow use of the nix language for my inputs, I use [genflake](https://github.com/jorsn/flakegen).
Therefore, the flake I edit is located at `./flake.in.nix`.
I also prefer using a more descriptive format for my inputs like so:
```nix ```nix
nixpkgs = { nixpkgs = {
@ -67,11 +70,6 @@ nixpkgs = {
to make it more clear what is what in the flake URI to make it more clear what is what in the flake URI
I also have a long list of inputs with `flake = false;` because
it makes it easier to update non-flake custom packages or overlays
to have the latest git. I make sure to end the names of these inputs
with `src` to make it clear what they are.
### Secrets ### Secrets
All my secrets are in a private git repo that makes use of All my secrets are in a private git repo that makes use of

View file

@ -52,6 +52,7 @@ in
*/ */
'' ''
require('lspconfig').nixd.setup(require('coq').lsp_ensure_capabilities({ require('lspconfig').nixd.setup(require('coq').lsp_ensure_capabilities({
filetypes = { 'nix', 'in.nix' },
settings = { settings = {
nixd = { nixd = {
formatting = { formatting = {

View file

@ -1,7 +1,7 @@
{ {
bat-theme-src, bat-theme-src,
gtk-theme-src, gtk-theme-src,
xresources-theme-src, xresources-src,
... ...
} @ inputs: (final: prev: { } @ inputs: (final: prev: {
dracula-theme = prev.dracula-theme.overrideAttrs (oldAttrs: let dracula-theme = prev.dracula-theme.overrideAttrs (oldAttrs: let
@ -21,7 +21,7 @@
cp -a ${bat-theme-src}/Dracula.tmTheme $out/bat cp -a ${bat-theme-src}/Dracula.tmTheme $out/bat
cp -a ${git-colors}/git-colors $out/git-colors cp -a ${git-colors}/git-colors $out/git-colors
cp -a ${plymouth}/share/plymouth/themes/dracula $out/share/plymouth/themes/ cp -a ${plymouth}/share/plymouth/themes/dracula $out/share/plymouth/themes/
cp -a ${xresources-theme-src}/Xresources $out/xres cp -a ${xresources-src}/Xresources $out/xres
# ------------------------------------------- # -------------------------------------------
mkdir -p $out/share/themes/Dracula mkdir -p $out/share/themes/Dracula

View file

@ -1,13 +1,13 @@
{ {
stdenv, stdenv,
plymouth-theme-src, dracula-plymouth-src,
... ...
}: }:
stdenv.mkDerivation { stdenv.mkDerivation {
name = "dracula-plymouth"; name = "dracula-plymouth";
version = plymouth-theme-src.shortRev; version = dracula-plymouth-src.shortRev;
src = plymouth-theme-src; src = dracula-plymouth-src;
installPhase = '' installPhase = ''
chmod 777 ./dracula chmod 777 ./dracula

View file

@ -1,8 +1,10 @@
{ {
home-manager, home-manager,
nix-on-droid,
nixpkgs, nixpkgs,
... ...
} @ inputs: rec { } @ inputs:
nix-on-droid.lib.nixOnDroidConfiguration rec {
extraSpecialArgs = inputs; extraSpecialArgs = inputs;
home-manager-path = home-manager.outPath; home-manager-path = home-manager.outPath;
pkgs = import nixpkgs { pkgs = import nixpkgs {

153
flake.in.nix Normal file
View file

@ -0,0 +1,153 @@
{
inputs = let
inherit (import ./input.nix) mkDep mkInput otherInputs;
mainInputs = {
nixpkgs = mkInput {
owner = "NixOS";
repo = "nixpkgs";
ref = "nixos-unstable";
};
home-manager = mkDep {
owner = "nix-community";
repo = "home-manager";
};
nix-on-droid = mkDep {
owner = "nix-community";
repo = "nix-on-droid";
inputs.home-manager.follows = "home-manager";
};
sops-nix = mkDep {
owner = "Mic92";
repo = "sops-nix";
};
secrets = mkDep {
type = "git";
url = "ssh://git@git.nelim.org/matt1432/nixos-secrets";
inputs.sops-nix.follows = "sops-nix";
};
};
in
mainInputs // otherInputs;
outputs = inputs @ {
self,
nixpkgs,
secrets,
...
}: let
supportedSystems = ["x86_64-linux" "aarch64-linux"];
perSystem = attrs:
nixpkgs.lib.genAttrs supportedSystems (system: let
pkgs = nixpkgs.legacyPackages.${system};
in
attrs system pkgs);
# Default system
mkNixOS = mods:
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = inputs;
modules =
[
{home-manager.extraSpecialArgs = inputs;}
./common
]
++ mods;
};
in {
nixosConfigurations = {
wim = mkNixOS [
./devices/wim
secrets.nixosModules.default
];
binto = mkNixOS [./devices/binto];
nos = mkNixOS [
./devices/nos
secrets.nixosModules.nos
];
servivi = mkNixOS [
./devices/servivi
secrets.nixosModules.servivi
];
# Cluster
thingone = mkNixOS [
(import ./devices/cluster "thingone")
secrets.nixosModules.thingy
];
thingtwo = mkNixOS [
(import ./devices/cluster "thingtwo")
secrets.nixosModules.thingy
];
live-image = mkNixOS [
("${nixpkgs}/nixos/modules/installer/"
+ "cd-dvd/installation-cd-minimal.nix")
{home-manager.users.nixos.home.stateVersion = "24.05";}
{
vars = {
mainUser = "nixos";
hostName = "nixos";
};
}
];
};
nixOnDroidConfigurations.default = import ./devices/android inputs;
formatter = perSystem (_: pkgs: pkgs.alejandra);
# CI: https://github.com/Mic92/dotfiles/blob/c2f538934d67417941f83d8bb65b8263c43d32ca/flake.nix#L168
checks = perSystem (system: pkgs: let
inherit (pkgs.lib) filterAttrs mapAttrs' nameValuePair;
nixosMachines = mapAttrs' (
name: config: nameValuePair "nixos-${name}" config.config.system.build.toplevel
) ((filterAttrs (_: config: config.pkgs.system == system)) self.nixosConfigurations);
devShells = mapAttrs' (n: nameValuePair "devShell-${n}") self.devShells;
in
nixosMachines // devShells);
devShells = perSystem (_: pkgs: {
default = pkgs.mkShell {
packages = with pkgs; [
alejandra
git
(writeShellScriptBin "mkIso" (lib.concatStrings [
"nix build $(realpath /etc/nixos)#nixosConfigurations."
"live-image.config.system.build.isoImage"
]))
];
};
ags = pkgs.mkShell {
packages = with pkgs; [
nodejs_latest
];
};
subtitles-dev = pkgs.mkShell {
packages = with pkgs;
[
nodejs_latest
ffmpeg-full
typescript
]
++ (with nodePackages; [
ts-node
]);
};
});
};
}

Binary file not shown.

BIN
flake.nix

Binary file not shown.

View file

@ -1,11 +1,11 @@
{ {
persist-properties-src, mpv-persist-properties-src,
buildLua, buildLua,
... ...
}: }:
buildLua { buildLua {
pname = "persist-properties"; pname = "persist-properties";
version = persist-properties-src.shortRev; version = mpv-persist-properties-src.shortRev;
src = persist-properties-src; src = mpv-persist-properties-src;
} }

View file

@ -1,11 +1,11 @@
{ {
pointer-event-src, mpv-pointer-event-src,
buildLua, buildLua,
... ...
}: }:
buildLua { buildLua {
pname = "pointer-event"; pname = "pointer-event";
version = pointer-event-src.shortRev; version = mpv-pointer-event-src.shortRev;
src = pointer-event-src; src = mpv-pointer-event-src;
} }

View file

@ -1,11 +1,11 @@
{ {
touch-gestures-src, mpv-touch-gestures-src,
buildLua, buildLua,
... ...
}: }:
buildLua { buildLua {
pname = "touch-gestures"; pname = "touch-gestures";
version = touch-gestures-src.shortRev; version = mpv-touch-gestures-src.shortRev;
src = touch-gestures-src; src = mpv-touch-gestures-src;
} }

319
input.nix Normal file
View file

@ -0,0 +1,319 @@
let
inherit (builtins) listToAttrs map removeAttrs;
# Misc functions
mkInput = {type ? "github", ...} @ info: info // {inherit type;};
mkDep = info: (mkInput info) // {inputs.nixpkgs.follows = "nixpkgs";};
mkSrc = info: (mkInput info) // {flake = false;};
# Inputs
nixTools = {
nurl = mkInput {
owner = "nix-community";
repo = "nurl";
};
nix-index-db = mkDep {
owner = "Mic92";
repo = "nix-index-database";
};
nh = mkInput {
owner = "viperML";
repo = "nh";
};
nix-melt = mkInput {
owner = "nix-community";
repo = "nix-melt";
};
};
overlays = {
nixpkgs-wayland = mkInput {
owner = "nix-community";
repo = "nixpkgs-wayland";
};
nur = mkInput {
owner = "nix-community";
repo = "NUR";
};
nix-gaming = mkInput {
owner = "fufexan";
repo = "nix-gaming";
};
};
nvimInputs = {
neovim-nightly = mkInput {
owner = "nix-community";
repo = "neovim-nightly-overlay";
# FIXME: issue with grammars on latest unstable
# inputs.nixpkgs.follows = "nixpkgs";
};
stylelint-lsp = mkDep {
owner = "matt1432";
repo = "stylelint-lsp";
};
nixd = mkInput {
owner = "nix-community";
repo = "nixd";
};
# FIXME: get it from nixpkgs when it gets merged
basedpyright.url = "github:kiike/nixpkgs/pkgs/basedpyright";
};
clusterInputs = {
pcsd = mkDep {
owner = "matt1432";
repo = "nixos-pcsd";
};
headscale = mkDep {
owner = "juanfont";
repo = "headscale";
# FIXME: doesn't work on latest
rev = "fef8261339899fe526777a7aa42df57ca02021c5";
};
caddy-plugins = mkDep {
owner = "matt1432";
repo = "nixos-caddy-cloudflare";
};
};
serviviInputs = {
nms = mkDep {
owner = "matt1432";
repo = "nixos-minecraft-servers";
};
nix-eval-jobs = mkDep {
owner = "nix-community";
repo = "nix-eval-jobs";
ref = "release-2.21";
};
nix-fast-build = mkDep {
owner = "Mic92";
repo = "nix-fast-build";
};
};
nosInputs = {
arion = mkDep {
owner = "hercules-ci";
repo = "arion";
};
jellyfin-flake = mkDep {
owner = "matt1432";
repo = "nixos-jellyfin";
};
bazarr-bulk = mkDep {
owner = "matt1432";
repo = "bazarr-bulk";
};
subsync = mkDep {
owner = "matt1432";
repo = "subsync";
# Keep version that uses Sphinxbase
rev = "ee9e1592ae4ec7c694d8857aa72be079d81ea209";
};
};
desktopInputs = {
hyprlandInputs = {
hyprland = mkDep {
type = "git";
url = "https://github.com/hyprwm/Hyprland";
submodules = true;
};
hypr-official-plugins = mkInput {
owner = "hyprwm";
repo = "hyprland-plugins";
inputs.hyprland.follows = "hyprland";
};
Hyprspace = mkInput {
owner = "KZDKM";
repo = "Hyprspace";
inputs.hyprland.follows = "hyprland";
};
hypridle = mkDep {
owner = "hyprwm";
repo = "hypridle";
};
grim-hyprland = mkDep {
owner = "eriedaberrie";
repo = "grim-hyprland";
};
## Wayland
wpaperd = mkDep {
owner = "danyspin97";
repo = "wpaperd";
};
};
agsInputs = {
ags = mkDep {
owner = "Aylur";
repo = "ags";
};
astal = mkDep {
owner = "Aylur";
repo = "Astal";
};
gtk-session-lock = mkDep {
owner = "Cu3PO42";
repo = "gtk-session-lock";
};
};
};
srcs = [
# Nvim plugins
{
name = "vimplugin-easytables-src";
owner = "Myzel394";
repo = "easytables.nvim";
}
{
name = "vimplugin-ts-error-translator-src";
owner = "dmmulroy";
repo = "ts-error-translator.nvim";
}
# Overlays & packages
{
owner = "rushsteve1";
repo = "trash-d";
}
{
type = "gitlab";
owner = "mishakmak";
repo = "pam-fprint-grosshack";
}
{
type = "gitlab";
owner = "phoneybadger";
repo = "pokemon-colorscripts";
}
{
owner = "Malpiszonekx4";
repo = "curseforge-server-downloader";
}
{
name = "gpu-screen-recorder-src";
type = "git";
url = "https://repo.dec05eba.com/gpu-screen-recorder";
}
{
owner = "libratbag";
repo = "libratbag";
}
{
owner = "libratbag";
repo = "piper";
}
# MPV scripts
{
name = "modernx-src";
owner = "cyl0";
repo = "ModernX";
}
{
owner = "d87";
repo = "mpv-persist-properties";
}
{
owner = "christoph-heinrich";
repo = "mpv-pointer-event";
}
{
owner = "christoph-heinrich";
repo = "mpv-touch-gestures";
}
{
name = "eisa-scripts-src";
owner = "Eisa01";
repo = "mpv-scripts";
}
## Theme sources
{
name = "jellyfin-ultrachromic-src";
owner = "CTalvio";
repo = "Ultrachromic";
}
{
name = "bat-theme-src";
owner = "matt1432";
repo = "bat";
}
{
owner = "Godiesc";
repo = "firefox-gx";
ref = "v.9.1";
}
{
name = "git-theme-src";
owner = "dracula";
repo = "git";
}
{
name = "gtk-theme-src";
owner = "dracula";
repo = "gtk";
}
{
name = "nvim-theme-src";
owner = "Mofiqul";
repo = "dracula.nvim";
}
{
owner = "matt1432";
repo = "dracula-plymouth";
}
{
owner = "dracula";
repo = "xresources";
}
];
in {
inherit mkDep mkInput mkSrc;
otherInputs =
nixTools
// overlays
// nvimInputs
// clusterInputs
// serviviInputs
// nosInputs
// desktopInputs.hyprlandInputs
// desktopInputs.agsInputs
// (listToAttrs (map (x: {
name = x.name or "${x.repo}-src";
value = mkSrc (removeAttrs x ["name"]);
})
srcs));
}