refactor: modularize flake and import nixpkgs
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-05-20 22:41:45 -04:00
parent 7a52fc6beb
commit 0861880a20
8 changed files with 160 additions and 138 deletions

19
ci.nix Normal file
View file

@ -0,0 +1,19 @@
# CI: https://github.com/Mic92/dotfiles/blob/c2f538934d67417941f83d8bb65b8263c43d32ca/flake.nix#L168
{
system,
pkgs,
self,
}: 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

View file

@ -23,10 +23,6 @@
../modules/nvidia.nix
];
nixpkgs = {
config.allowUnfree = true;
overlays = import ./overlays inputs;
};
boot.tmp.useTmpfs = true;
nix = {

View file

@ -1,8 +1,7 @@
{
basedpyrightPkgs,
config,
lib,
pkgs,
basedpyright,
...
}: let
inherit (config.vars) neovimIde;
@ -13,7 +12,7 @@ in
withPython3 = true;
extraPackages = [
basedpyright.legacyPackages.${pkgs.system}.basedpyright
basedpyrightPkgs.basedpyright
];
extraLuaConfig =

View file

@ -23,16 +23,10 @@
substituters = [
# Nix-community
"https://nix-community.cachix.org"
# FIXME: cache doesn't work
# Personal config cache
# "https://cache.nelim.org"
];
trustedPublicKeys = [
# Nix-community
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
# Personal config cache
# "cache.nelim.org:JmFqkUdH11EA9EZOFAGVHuRYp7EbsdJDHvTQzG2pPyY="
];
};

View file

@ -1,27 +1,72 @@
{
home-manager,
nix-on-droid,
nixpkgs,
config,
lib,
pkgs,
...
} @ inputs:
nix-on-droid.lib.nixOnDroidConfiguration rec {
extraSpecialArgs = inputs;
home-manager-path = home-manager.outPath;
pkgs = import nixpkgs {
system = "aarch64-linux";
overlays = import ../../common/overlays inputs;
}: {
vars = {
mainUser = "nix-on-droid";
hostName = "localhost";
neovimIde = false;
};
modules = [
{
options = with pkgs.lib; {
environment.variables.FLAKE = mkOption {
type = with types; nullOr str;
};
};
}
{home-manager.extraSpecialArgs = inputs;}
../../common/nix-on-droid.nix
./nix-on-droid.nix
environment.variables.FLAKE = "/data/data/com.termux.nix/files/home/.nix";
terminal.font = "${(pkgs.nerdfonts.override {
fonts = [
"JetBrainsMono"
];
})}/share/fonts/truetype/NerdFonts/JetBrainsMonoNerdFontMono-Regular.ttf";
environment.packages =
(with pkgs; [
diffutils
findutils
utillinux
tzdata
hostname
man
gnugrep
ripgrep
gnupg
gnused
gnutar
bzip2
gzip
xz
zip
unzip
openssh
perl
which
alejandra
])
++ [
(pkgs.writeShellApplication {
name = "switch";
runtimeInputs = with pkgs; [
nix-output-monitor
];
text = ''
exec nix-on-droid ${lib.concatStringsSep " " [
"switch"
"--flake ${config.environment.variables.FLAKE}"
"--builders ssh-ng://matt@100.64.0.7"
''"$@"''
"|&"
"nom"
]}
'';
})
];
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,72 +0,0 @@
{
config,
lib,
pkgs,
...
}: {
vars = {
mainUser = "nix-on-droid";
hostName = "localhost";
neovimIde = false;
};
environment.variables.FLAKE = "/data/data/com.termux.nix/files/home/.nix";
terminal.font = "${(pkgs.nerdfonts.override {
fonts = [
"JetBrainsMono"
];
})}/share/fonts/truetype/NerdFonts/JetBrainsMonoNerdFontMono-Regular.ttf";
environment.packages =
(with pkgs; [
diffutils
findutils
utillinux
tzdata
hostname
man
gnugrep
ripgrep
gnupg
gnused
gnutar
bzip2
gzip
xz
zip
unzip
openssh
perl
which
alejandra
])
++ [
(pkgs.writeShellApplication {
name = "switch";
runtimeInputs = with pkgs; [
nix-output-monitor
];
text = ''
exec nix-on-droid ${lib.concatStringsSep " " [
"switch"
"--flake ${config.environment.variables.FLAKE}"
"--builders ssh-ng://matt@100.64.0.7"
''"$@"''
"|&"
"nom"
]}
'';
})
];
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

@ -42,39 +42,29 @@
secrets,
...
}: let
inherit (import ./lib.nix inputs) mkNixOS mkNixOnDroid mkPkgs;
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;
};
nixpkgs.lib.genAttrs supportedSystems (system:
attrs system (mkPkgs system nixpkgs));
in {
nixosConfigurations = {
# Desktops
wim = mkNixOS [
./devices/wim
secrets.nixosModules.default
];
binto = mkNixOS [./devices/binto];
# NAS
nos = mkNixOS [
./devices/nos
secrets.nixosModules.nos
];
# Build / test server
servivi = mkNixOS [
./devices/servivi
secrets.nixosModules.servivi
@ -103,20 +93,7 @@
];
};
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);
nixOnDroidConfigurations.default = mkNixOnDroid [./devices/android];
devShells = perSystem (_: pkgs: {
default = pkgs.mkShell {
@ -149,5 +126,12 @@
]);
};
});
formatter = perSystem (_: pkgs: pkgs.alejandra);
# For nix-fast-build
checks =
perSystem (system: pkgs:
import ./ci.nix {inherit system pkgs self;});
};
}

57
lib.nix Normal file
View file

@ -0,0 +1,57 @@
{
basedpyright,
home-manager,
nix-on-droid,
nixpkgs,
...
} @ inputs: rec {
# Import pkgs from a nixpkgs
mkPkgs = system: input:
import input {
inherit system;
config.allowUnfree = true;
overlays = import ./common/overlays inputs;
};
# Function that makes the attrs that make up the specialArgs
mkArgs = system:
inputs
// {
pkgs = mkPkgs system nixpkgs;
basedpyrightPkgs = mkPkgs system basedpyright;
};
# Default system
mkNixOS = mods:
nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
specialArgs = mkArgs system;
modules =
[
{home-manager.extraSpecialArgs = specialArgs;}
./common
]
++ mods;
};
mkNixOnDroid = mods:
nix-on-droid.lib.nixOnDroidConfiguration rec {
extraSpecialArgs = mkArgs "aarch64-linux";
home-manager-path = home-manager.outPath;
pkgs = extraSpecialArgs.pkgs;
modules =
[
{
options = with pkgs.lib; {
environment.variables.FLAKE = mkOption {
type = with types; nullOr str;
};
};
}
{home-manager = {inherit extraSpecialArgs;};}
./common/nix-on-droid.nix
]
++ mods;
};
}