Skip to content

Commit

Permalink
feat(modules): i honestly dk anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
bddvlpr committed Jul 13, 2024
1 parent e5ac755 commit 90fccf7
Show file tree
Hide file tree
Showing 22 changed files with 287 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/result
*.qcow2
*.qcow2
1 change: 0 additions & 1 deletion checks/fmt.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
mkTest,
pkgs,
lib,
self,
alejandra,
Expand Down
2 changes: 1 addition & 1 deletion checks/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pkgs,
lib,
...
} @ args: let
}: let
inherit (lib) callPackageWith;

mkTest = test:
Expand Down
92 changes: 46 additions & 46 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";

hardware.url = "github:nixos/nixos-hardware";

flake-parts.url = "github:hercules-ci/flake-parts";

impermanence.url = "github:nix-community/impermanence";

disko.url = "github:nix-community/disko";
Expand Down Expand Up @@ -46,22 +48,27 @@
outputs = {flake-parts, ...} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = [
"aarch64-linux"
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];

imports = [
./apps/module.nix
./checks/module.nix
./lib/module.nix
./modules/module.nix
./overlays/module.nix
./pkgs/module.nix
./systems/module.nix
];

perSystem = {pkgs, ...}: {
perSystem = {
pkgs,
inputs',
...
}: {
formatter = pkgs.alejandra;
};
};
Expand Down
42 changes: 42 additions & 0 deletions lib/module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
self,
lib,
inputs,
withSystem,
...
}: let
inherit (self) outputs;
inherit (lib.strings) hasSuffix;
in {
flake.lib = rec {
mkPkgs = system:
import inputs.nixpkgs {
inherit system;
overlays = with outputs.overlays; [pkgs];
config.allowUnfree = true;
};

mkSystem = host: system: type: modules:
withSystem system ({pkgs, ...}:
type {
inherit system modules;
pkgs = mkPkgs system;
specialArgs = {inherit inputs outputs host;};
});

mkStrappedSystem = host: system: type: modules: let
inherit (builtins) attrValues;

isLinux = hasSuffix "linux" system;
in
mkSystem host system type (
modules
++ (
if isLinux
then attrValues outputs.nixosModules
else attrValues outputs.darwinModules
)
++ attrValues outputs.sharedModules
);
};
}
3 changes: 1 addition & 2 deletions modules/darwin/home-manager/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ in {
options.sysc.home-manager = {
enable = mkOption {
type = types.bool;
default = true;
default = false;
description = "Whether to enable home-manager.";
};
};
Expand All @@ -28,7 +28,6 @@ in {
users.bddvlpr = import ./users/bddvlpr.nix;
extraSpecialArgs = {
inherit inputs outputs system;
nixosConfig = config;
};
};
};
Expand Down
29 changes: 29 additions & 0 deletions modules/home/cura/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
lib,
config,
pkgs,
...
}: let
inherit (lib) mkIf mkOption types;

cfg = config.sysc.cura;
in {
options.sysc.cura = {
enable = mkOption {
type = types.bool;
default = false;
description = "Whether to enable Cura.";
};
};

config = mkIf cfg.enable {
home = {
packages = with pkgs; [cura];

persistence."/persist/home/bddvlpr".directories = [
".config/cura"
".local/share/cura"
];
};
};
}
2 changes: 1 addition & 1 deletion modules/home/freecad/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ in {
options.sysc.freecad = {
enable = mkOption {
type = types.bool;
default = true;
default = false;
description = "Whether to enable FreeCAD.";
};
};
Expand Down
Loading

0 comments on commit 90fccf7

Please sign in to comment.