blob: 5ea37b73e8615d7e07882df2b929fdd38cd8a6b1 [file] [log] [blame]
{
description = "Minion's NixOS configuration (since 2022-08-19)";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs-minion.url = "github:Minion3665/nixpkgs";
nixpkgs-yubioath-flutter.url = "github:lukegb/nixpkgs/yubioath-flutter";
flake-utils.url = "github:numtide/flake-utils";
flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus";
vscode-extensions.url = "github:AmeerTaweel/nix-vscode-marketplace";
registry = {
url = "github:nixos/flake-registry";
flake = false;
};
home-manager.url = "github:nix-community/home-manager";
sops-nix.url = "github:Mic92/sops-nix";
impermanence.url = "github:nix-community/impermanence";
gtimelog = {
url = "git+https://gitlab.collabora.com/collabora/gtimelog.git";
flake = false;
};
fzf-tab = {
url = "github:Aloxaf/fzf-tab";
flake = false;
};
omnisharp-language-server = {
url = "github:coc-extensions/coc-omnisharp";
flake = false;
};
kmonad = {
url = "github:kmonad/kmonad?dir=nix";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix.url = "github:nix-community/fenix";
nps.url = "github:OleMussmann/Nix-Package-Search";
fenix.inputs.nixpkgs.follows = "nixpkgs";
flake-utils-plus.inputs.flake-utils.follows = "flake-utils";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
nps.inputs.nixpkgs.follows = "nixpkgs";
nps.inputs.flake-utils.follows = "flake-utils";
};
outputs = inputs:
let
inherit (inputs) self nixpkgs flake-utils;
in
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = import ./overlays nixpkgs.lib (inputs // {
inherit inputs
username;
});
};
utils = import ./utils nixpkgs.lib;
username = "minion";
isAttrType = type:
if builtins.elem type.name [ "submodule" ]
then true
else if type ? nestedTypes.elemType
then isAttrType type.nestedTypes.elemType
else false;
normalizeOptions = options:
if
nixpkgs.lib.traceSeqN 2
{
inherit options;
type = builtins.typeOf options;
}
builtins.typeOf
options
== "set"
then
nixpkgs.lib.mapAttrs
(
name: value:
if
nixpkgs.lib.traceSeqN 3
{
inherit name value;
hasGetSubOpts = value ? getSubOptions;
hasType = value ? type;
isAttrType = value ? type && isAttrType value.type;
typeName = value.type.name or "unnamed";
type = builtins.typeOf value;
}
(builtins.typeOf value)
== "set"
then
nixpkgs.lib.traceVal
(normalizeOptions (
if value ? type && isAttrType value.type
then nixpkgs.lib.traceVal (value.type.getSubOptions [ ])
else nixpkgs.lib.traceVal value
))
else value
)
options
else options;
evalTrace = config: trace:
let
lib = nixpkgs.lib;
splitTrace = lib.splitString "." trace;
traceHead = builtins.head splitTrace;
traceTail = builtins.tail splitTrace;
resolvedTrace =
(
if traceHead == "home"
then [ "home-manager" "users" username ]
else lib.errorIfNot (traceHead == "config") [ ]
)
++ traceTail;
in
(
lib.pipe resolvedTrace [
(lib.foldl
({ value
, error
,
}: key:
if builtins.hasAttr key value
then {
value = value.${key};
inherit error;
}
else {
value = { };
error = true;
})
{
value = { };
error = false;
})
(data: lib.warnIf data.error "trace/${trace} is invalid; the key does not exist" data)
({ value
, error
,
}: {
value = builtins.toJSON value;
inherit error;
})
({ value
, error
,
}: {
value = "trace/${trace}: ${value}";
inherit error;
})
({ value
, error
,
}:
lib.traceIf (!error) value null)
]
);
in
{
packages.nixosConfigurations = {
default = nixpkgs.lib.traceValFn
(nixosSystem: map (evalTrace nixosSystem.config)
nixosSystem.config.internal.traces)
(nixpkgs.lib.nixosSystem
{
inherit system;
modules = [
(nixpkgs.lib.pipe ./modules [
utils.nixFilesIn
(utils.interpretNonstandardModule (args:
args
// {
home = args.config.home-manager.users.${username};
home-options =
nixpkgs.lib.traceVal (normalizeOptions
(args.options.home-manager.users.type.getSubOptions [ ]));
inherit system utils;
}))
])
{
minion = import ./config.nix;
}
];
specialArgs = inputs // { inherit inputs username; };
});
};
devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ nodePackages.prettier nixpkgs-fmt ];
buildInputs = [ ];
};
formatter = pkgs.nixpkgs-fmt;
});
}