mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-30 22:57:55 +00:00
flake: add basic-nix-module-flake template
This commit is contained in:
parent
79e118e609
commit
473540b952
@ -6,6 +6,10 @@
|
||||
path = ../../templates/basic-devshell;
|
||||
description = "Basic development shell template";
|
||||
};
|
||||
basic-nix-module-flake = {
|
||||
path = ../../templates/basic-nix-module-flake;
|
||||
description = "Basic Nix module flake template";
|
||||
};
|
||||
basic-overlay-flake = {
|
||||
path = ../../templates/basic-overlay-flake;
|
||||
description = "Basic overlay as a flake";
|
||||
|
20
templates/basic-nix-module-flake/flake.nix
Normal file
20
templates/basic-nix-module-flake/flake.nix
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
description = "Basic Nix module flake description";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
};
|
||||
|
||||
outputs = inputs@{ self, nixpkgs, ... }:
|
||||
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
|
||||
imports = [
|
||||
./nix/flake
|
||||
];
|
||||
};
|
||||
}
|
32
templates/basic-nix-module-flake/nix/flake/default.nix
Normal file
32
templates/basic-nix-module-flake/nix/flake/default.nix
Normal file
@ -0,0 +1,32 @@
|
||||
{ lib, inputs, ... }: {
|
||||
flake = {
|
||||
nixosModules.default = ../modules;
|
||||
};
|
||||
|
||||
perSystem = { lib, pkgs, system, ... }: {
|
||||
formatter = pkgs.treefmt;
|
||||
|
||||
devShells.default = import ../../shell.nix { inherit pkgs; };
|
||||
|
||||
# Just make sure it actually compiles with a very minimal NixOS
|
||||
# configuration.
|
||||
checks.nixos-module-test =
|
||||
let
|
||||
nixosSystem = args:
|
||||
import "${inputs.nixpkgs}/nixos/lib/eval-config.nix" args;
|
||||
in
|
||||
nixosSystem {
|
||||
modules = [
|
||||
({ modulesPath, ... }: {
|
||||
imports = [
|
||||
"${modulesPath}/profiles/minimal.nix"
|
||||
];
|
||||
|
||||
nixpkgs.hostPlatform = system;
|
||||
boot.loader.grub.enable = false;
|
||||
fileSystems."/".device = "nodev";
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
21
templates/basic-nix-module-flake/nix/modules/default.nix
Normal file
21
templates/basic-nix-module-flake/nix/modules/default.nix
Normal file
@ -0,0 +1,21 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.programs.foo;
|
||||
|
||||
settingsFormat = pkgs.format.json { };
|
||||
in
|
||||
{
|
||||
options.programs.foo = {
|
||||
enable = lib.mkEnableOption "foo, a sample program";
|
||||
package = lib.mkPackageOption pkgs "foo" { };
|
||||
settings = lib.mkOption {
|
||||
type = settingsFormat.type;
|
||||
default = { };
|
||||
# TODO: Don't forget to set an example here.
|
||||
description = ''
|
||||
The settings of the program.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
10
templates/basic-nix-module-flake/shell.nix
Normal file
10
templates/basic-nix-module-flake/shell.nix
Normal file
@ -0,0 +1,10 @@
|
||||
{ pkgs ? import <nixpkgs> { } }:
|
||||
|
||||
with pkgs;
|
||||
|
||||
mkShell {
|
||||
packages = [
|
||||
nixpkgs-fmt
|
||||
treefmt
|
||||
];
|
||||
}
|
3
templates/basic-nix-module-flake/treefmt.toml
Normal file
3
templates/basic-nix-module-flake/treefmt.toml
Normal file
@ -0,0 +1,3 @@
|
||||
[formatter.nix]
|
||||
command = "nixpkgs-fmt"
|
||||
includes = [ "*.nix" ]
|
Loading…
Reference in New Issue
Block a user