Add modules

This commit is contained in:
Victor Fuentes 2022-09-25 23:02:46 -04:00
parent 2a1d72434b
commit 5e40ef349d
No known key found for this signature in database
GPG Key ID: 0A88B68D6A9ACAE0
2 changed files with 38 additions and 0 deletions

View File

@ -5,6 +5,10 @@
};
outputs = { self, nixpkgs, utils }:
{
nixosModules.nix-software-center = import ./modules/default.nix;
nixosModules.default = self.nixosModules.nix-software-center;
} //
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {

34
modules/default.nix Normal file
View File

@ -0,0 +1,34 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.nix-software-center;
jsonFormat = pkgs.formats.json { };
in
{
options = {
programs.nix-software-center = {
systemconfig = mkOption {
type = with types; nullOr str;
default = null;
example = literalExpression ''"/etc/nixos/configuration.nix"'';
description = ''Where Nix Software Center looks for your system configuration.'';
};
flake = mkOption {
type = with types; nullOr str;
default = null;
example = literalExpression ''"/etc/nixos/flake.nix"'';
description = ''Where Nix Software Center looks for your system flake file.'';
};
flakearg = mkOption {
type = with types; nullOr str;
default = null;
example = literalExpression ''user'';
description = ''The flake argument to use when rebuilding the system. `nixos-rebuild switch --flake $\{programs.nix-software-center.flake}#$\{programs.nix-software-center.flakearg}`'';
};
};
};
config = mkIf (cfg.systemconfig != null || cfg.flake != null || cfg.flakearg != null) {
environment.etc."nix-software-center/config.json".source = jsonFormat.generate "config.json" cfg;
};
}