Refactor modules #356

Merged
jalil merged 4 commits from push-wlplzqkzpztr into main 2025-03-16 19:22:30 +01:00
30 changed files with 132 additions and 111 deletions

View file

@ -3,22 +3,13 @@ on:
jobs:
check:
runs-on: nixos
strategy:
matrix:
check:
- nvimDev
- nvimHeadless
- nvimNoBundledBins
- nvimNoLsp
- nvimNoTSGrammars
- treefmt
steps:
- uses: "https://git.salame.cl/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4
- name: Run checks
run: |
nix --version
# shellcheck disable=SC2016
nix build --print-build-logs '.#checks.x86_64-linux.${{ matrix.check }}'
nix-fast-build --max-jobs 2 --no-nom --skip-cached --no-link \
--flake ".#checks.$(nix eval --raw --impure --expr builtins.currentSystem)"
check-renovaterc:
runs-on: nixos
steps:
@ -27,24 +18,25 @@ jobs:
run: |
nix --version
nix shell nixpkgs#renovate --command renovate-config-validator
build:
build-packages:
runs-on: nixos
needs: check
strategy:
matrix:
target:
- audiomenu
- docs
- jpassmenu
- nixosConfigurations.vm.config.system.build.toplevel
- nvim
steps:
- uses: "https://git.salame.cl/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4
- name: Build target
run: |
nix --version
# shellcheck disable=SC2016
nix build --print-build-logs '.#${{ matrix.target }}'
nix-fast-build --max-jobs 2 --no-nom --skip-cached --no-link \
--flake ".#packages.$(nix eval --raw --impure --expr builtins.currentSystem)"
build-vm:
runs-on: nixos
needs: build-packages
steps:
- uses: "https://git.salame.cl/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4
- name: Build VM configuration
run: |
nix --version
nix build --print-build-logs '.#nixosConfigurations.vm.config.system.build.toplevel'
report-size:
runs-on: nixos
needs: build

View file

@ -10,7 +10,8 @@ in
./docs.nix
./example-vm.nix
./nixos-modules.nix
./nvim.nix
./home-modules.nix
./nixvim-modules.nix
./overlays.nix
./scripts.nix
];

View file

@ -5,17 +5,18 @@
{
packages =
let
modules = ../modules;
filterVisible =
toplevelOption: option:
option // { visible = option.visible && builtins.elemAt option.loc 0 == toplevelOption; };
home-eval = lib.evalModules {
modules = [ ../home/options.nix ];
modules = [ (modules + "/hm/options.nix") ];
specialArgs = {
inherit pkgs;
};
};
nvim-eval = lib.evalModules { modules = [ ../nvim/options.nix ]; };
nixos-eval = lib.evalModules { modules = [ ../system/options.nix ]; };
nvim-eval = lib.evalModules { modules = [ (modules + "/nixvim/options.nix") ]; };
nixos-eval = lib.evalModules { modules = [ (modules + "/nixos/options.nix") ]; };
home-markdown =
(pkgs.nixosOptionsDoc {
inherit (home-eval) options;

View file

@ -0,0 +1,34 @@
{ self, inputs, ... }:
let
modules = ../modules;
in
{
# FIXME(25.05): this version of HM should have the flake module
# imports = [ inputs.home-manager.flakeModules.home-manager ];
flake.homeModules =
let
defaultModules = [
inputs.nixvim.homeManagerModules.nixvim
self.nixvimModules.homeManager
(modules + "/hm")
];
nixos = {
imports = defaultModules;
};
standalone = {
imports = defaultModules ++ [
inputs.stylix.homeManagerModules.stilyx
(
{ config, ... }:
{
stylix.image = config.jhome.sway.background;
}
)
];
};
in
{
inherit standalone nixos;
};
}

View file

@ -1,27 +1,25 @@
{ inputs, lib, ... }:
{
self,
inputs,
lib,
...
}:
let
modules = ../modules;
in
{
flake.nixosModules =
let
nvim-config = {
imports = [
inputs.nixvim.homeManagerModules.nixvim
../nvim
];
};
homeManagerModuleSandalone = import ../home {
inherit nvim-config;
inherit (inputs) stylix;
};
homeManagerModuleNixOS = import ../home { inherit nvim-config; };
nixosModule = {
imports = [
(import ../system { inherit (inputs) stylix; })
inputs.stylix.nixosModules.stylix
inputs.home-manager.nixosModules.home-manager
(modules + "/nixos")
] ++ lib.optional (inputs.lix-module != null) inputs.lix-module.nixosModules.default;
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
sharedModules = [ homeManagerModuleNixOS ];
sharedModules = [ self.homeModules.nixos ];
};
# Pin nixpkgs
nix.registry.nixpkgs.flake = inputs.nixpkgs;
@ -39,7 +37,7 @@
in
{
default = nixosModule;
inherit nixosModule homeManagerModuleNixOS homeManagerModuleSandalone;
inherit nixosModule;
}
// machineModules;
}

View file

@ -0,0 +1,60 @@
{ self, inputs, ... }:
let
modules = ../modules;
in
{
imports = [ inputs.nixvim.flakeModules.default ];
nixvim = {
packages.enable = true;
checks.enable = false; # FIXME: borked due to nix-community/nixvim#3074
};
flake.nixvimModules = {
standalone = modules + "/nixvim/standalone.nix";
homeManager = modules + "/nixvim";
};
perSystem =
{ system, ... }:
let
nvimModule = extraConfig: {
inherit system;
modules = [
self.nixvimModules.standalone
{ performance.combinePlugins.enable = true; }
extraConfig
];
};
modules = {
nvim = nvimModule { };
# Smaller derivations
nvim-headless = nvimModule {
jhome.nvim.dev.enable = false;
jhome.nvim.reduceSize = true;
};
nvim-small = nvimModule {
jhome.nvim.dev.bundleLSPs = false;
};
nvim-no-ts = nvimModule {
jhome.nvim.dev.bundleGrammars = false;
};
nvim-no-lsps = nvimModule {
jhome.nvim.dev = {
bundleLSPs = false;
bundleGrammars = false;
};
};
};
in
{
checks = builtins.mapAttrs (
_name: module:
inputs.nixvim.lib.${system}.check.mkTestDerivationFromNixvimModule {
module.imports = module.modules;
}
) modules;
nixvimConfigurations = builtins.mapAttrs (_name: inputs.nixvim.lib.evalNixvim) modules;
};
}

View file

@ -1,53 +0,0 @@
{ inputs, ... }:
{
perSystem =
{ lib, system, ... }:
let
nixvimLib = inputs.nixvim.lib.${system};
nixvim = inputs.nixvim.legacyPackages.${system};
testNvimModule = nixvimLib.check.mkTestDerivationFromNixvimModule;
nvimModule = extraConfig: {
pkgs = inputs.unstable.legacyPackages.${system};
module = {
imports = [ ../nvim/standalone.nix ];
config = lib.mkMerge [
{ performance.combinePlugins.enable = true; }
extraConfig
];
};
};
moduleDev = nvimModule { };
moduleHeadless = nvimModule {
jhome.nvim.dev.enable = false;
jhome.nvim.reduceSize = true;
};
moduleNoLsp = nvimModule { jhome.nvim.dev.bundleLSPs = false; };
moduleNoTSGrammars = nvimModule { jhome.nvim.dev.bundleGrammars = false; };
moduleNoBundledBins = nvimModule {
jhome.nvim.dev = {
bundleLSPs = false;
bundleGrammars = false;
};
};
in
{
# Check standalone nvim build
checks = {
nvimDev = testNvimModule moduleDev;
nvimHeadless = testNvimModule moduleHeadless;
nvimNoLsp = testNvimModule moduleNoLsp;
nvimNoTSGrammars = testNvimModule moduleNoTSGrammars;
nvimNoBundledBins = testNvimModule moduleNoBundledBins;
};
# Nvim standalone module
packages = {
nvim = nixvim.makeNixvimWithModule moduleDev;
# Smaller derivations
nvim-headless = nixvim.makeNixvimWithModule moduleHeadless;
nvim-small = nixvim.makeNixvimWithModule moduleNoBundledBins;
nvim-no-ts = nixvim.makeNixvimWithModule moduleNoTSGrammars;
nvim-no-lsps = nixvim.makeNixvimWithModule moduleNoLsp;
};
};
}

View file

@ -1,7 +1,3 @@
{
nvim-config,
stylix ? null,
}:
{
config,
pkgs,
@ -17,16 +13,10 @@ let
path: default: if osConfig == null then default else lib.attrsets.attrByPath path default osConfig;
in
{
imports =
[
nvim-config
imports = [
./options.nix
./gui
./users.nix
]
++ lib.optionals (stylix != null) [
stylix.homeManagerModules.stylix
{ stylix.image = cfg.sway.background; }
];
config = lib.mkMerge [

View file

@ -1,4 +1,3 @@
{ stylix }:
{
config,
pkgs,
@ -22,7 +21,6 @@ in
imports = [
./options.nix
./gui
stylix.nixosModules.stylix
{ stylix = import ./stylix-config.nix { inherit config pkgs; }; }
];