refactor(flake): move some code out of flake.in.nix
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-07-21 17:12:26 -04:00
parent b3b65c1bd9
commit c701e335d1
39 changed files with 54 additions and 42 deletions

12
apps/default.nix Normal file
View file

@ -0,0 +1,12 @@
{
inputs,
pkgs,
...
}: let
mkApp = file: {
program = pkgs.callPackage file ({} // inputs);
type = "app";
};
in {
updateFlake = mkApp ./update;
}

View file

@ -53,7 +53,7 @@
perSystem = attrs: perSystem = attrs:
nixpkgs.lib.genAttrs supportedSystems (system: nixpkgs.lib.genAttrs supportedSystems (system:
attrs system (mkPkgs system nixpkgs)); attrs (mkPkgs system nixpkgs));
in { in {
nixosModules = { nixosModules = {
adb = import ./modules/adb.nix; adb = import ./modules/adb.nix;
@ -95,8 +95,7 @@
]; ];
live-image = mkNixOS [ live-image = mkNixOS [
("${nixpkgs}/nixos/modules/installer/" "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
+ "cd-dvd/installation-cd-minimal.nix")
{home-manager.users.nixos.home.stateVersion = "24.05";} {home-manager.users.nixos.home.stateVersion = "24.05";}
{ {
vars = { vars = {
@ -107,33 +106,28 @@
]; ];
}; };
nixOnDroidConfigurations.default = mkNixOnDroid [./devices/android]; nixOnDroidConfigurations.default =
mkNixOnDroid [./devices/android];
legacyPackages = perSystem (system: pkgs: let legacyPackages =
mkScope = file: perSystem (pkgs:
pkgs.lib.recurseIntoAttrs import ./legacyPackages {inherit mkVersion pkgs inputs;});
(pkgs.callPackage file ({inherit mkVersion;} // inputs));
in {
dracula = mkScope ./pkgs/dracula;
firefoxAddons = mkScope ./pkgs/firefox-addons;
mpvScripts = mkScope ./pkgs/mpv-scripts;
});
packages = packages =
perSystem (system: pkgs: perSystem (pkgs:
import ./pkgs ({inherit self system pkgs mkVersion;} // inputs)); import ./packages {inherit self pkgs mkVersion inputs;});
devShells = perSystem (_: pkgs: { apps =
perSystem (pkgs:
import ./apps {inherit inputs pkgs;});
devShells = perSystem (pkgs: {
default = pkgs.mkShell { default = pkgs.mkShell {
packages = with pkgs; [ packages = with pkgs; [
alejandra (writeShellScriptBin "mkIso" ''
git isoConfig="nixosConfigurations.live-image.config.system.build.isoImage"
nix-output-monitor nom build $(realpath /etc/nixos)#$isoConfig
'')
(writeShellScriptBin "mkIso" (lib.concatStrings [
"nom build $(realpath /etc/nixos)#nixosConfigurations."
"live-image.config.system.build.isoImage"
]))
]; ];
}; };
@ -161,21 +155,11 @@
}; };
}); });
formatter = perSystem (_: pkgs: pkgs.alejandra);
# Scripts
apps = perSystem (system: pkgs: let
inherit (pkgs) lib callPackage;
in {
updateFlake = {
program = lib.getExe (callPackage ./apps/update ({} // inputs));
type = "app";
};
});
# For nix-fast-build # For nix-fast-build
checks = checks =
perSystem (system: pkgs: perSystem (pkgs:
import ./flake/ci.nix {inherit system pkgs self;}); import ./flake/ci.nix {inherit pkgs self;});
formatter = perSystem (pkgs: pkgs.alejandra);
}; };
} }

View file

@ -1,6 +1,5 @@
# CI: https://github.com/Mic92/dotfiles/blob/c2f538934d67417941f83d8bb65b8263c43d32ca/flake.nix#L168 # CI: https://github.com/Mic92/dotfiles/blob/c2f538934d67417941f83d8bb65b8263c43d32ca/flake.nix#L168
{ {
system,
pkgs, pkgs,
self, self,
}: let }: let
@ -9,6 +8,6 @@
nixosMachines = nixosMachines =
mapAttrs' mapAttrs'
(name: config: nameValuePair "nixos-${name}" config.config.system.build.toplevel) (name: config: nameValuePair "nixos-${name}" config.config.system.build.toplevel)
((filterAttrs (_: config: config.pkgs.system == system)) self.nixosConfigurations); ((filterAttrs (_: config: config.pkgs.system == pkgs.system)) self.nixosConfigurations);
in in
nixosMachines nixosMachines

View file

@ -0,0 +1,16 @@
{
inputs,
mkVersion,
pkgs,
...
}: let
inherit (pkgs) lib;
mkScope = file:
lib.recurseIntoAttrs
(pkgs.callPackage file ({inherit mkVersion;} // inputs));
in {
dracula = mkScope ./dracula;
firefoxAddons = mkScope ./firefox-addons;
mpvScripts = mkScope ./mpv-scripts;
}

View file

@ -1,8 +1,9 @@
{ {
pkgs, inputs,
mkVersion, mkVersion,
pkgs,
... ...
} @ inputs: { }: {
coloryou = pkgs.callPackage ./coloryou {}; coloryou = pkgs.callPackage ./coloryou {};
gpu-screen-recorder = pkgs.callPackage ./gpu-screen-recorder { gpu-screen-recorder = pkgs.callPackage ./gpu-screen-recorder {