nixos/flake/perSystem.nix

77 lines
1.8 KiB
Nix
Raw Permalink Normal View History

{
inputs,
rootPath,
...
2025-07-13 06:04:55 +08:00
}:
{
imports = [
(rootPath + "/treefmt.nix")
];
2025-07-13 06:04:55 +08:00
perSystem =
{
pkgs,
system,
lib,
self',
inputs',
...
}:
let
inherit (inputs) nixpkgs;
in
2025-07-13 06:04:55 +08:00
{
_module.args.pkgs = import nixpkgs {
localSystem = { inherit system; };
2025-07-13 06:04:55 +08:00
config = {
allowUnfree = true;
};
overlays = [ (_final: _prev: { inherit lib; }) ];
};
2025-07-13 06:04:55 +08:00
devShells.default = pkgs.mkShell {
name = "nixos-shell";
packages = with pkgs; [
nixd
nil
typos
typos-lsp
just
nvfetcher
nixfmt-rfc-style
2025-10-22 00:59:37 +08:00
lua-language-server
2025-07-13 06:04:55 +08:00
];
};
legacyPackages =
let
inputsScope = lib.makeScope pkgs.newScope (self: {
inherit inputs rootPath;
srcs = self.callPackage (rootPath + "/_sources/generated.nix") { };
inherit (inputs'.nixvim.legacyPackages) makeNixvim makeNixvimWithModule;
inherit (self'.legacyPackages) nixvimPlugins editor-runtime;
2025-07-13 06:04:55 +08:00
neovim_git = inputs'.neovim-nightly.packages.default;
});
in
lib.packagesFromDirectoryRecursive {
inherit (inputsScope) callPackage;
directory = rootPath + "/pkgs";
};
packages =
let
flattenPkgs =
path: value:
if lib.isDerivation value then
{
${lib.concatStringsSep "/" path} = value;
}
else if lib.isAttrs value then
lib.concatMapAttrs (name: flattenPkgs (path ++ [ name ])) value
else
{ };
in
flattenPkgs [ ] self'.legacyPackages;
checks = lib.concatMapAttrs (name: value: {
"package-${name}" = value;
2025-07-13 06:04:55 +08:00
}) self'.packages;
};
}