Skip to content

Commit

Permalink
Make use of specialArgs WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
573 committed Sep 18, 2024
1 parent 5eb475e commit ad8a850
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 78 deletions.
5 changes: 5 additions & 0 deletions flake/builders/mkHome.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ inputs.home-manager.lib.homeManagerConfiguration {
pkgs = pkgsFor.${system};
/**
as in ./../../lib/common-config.nix `homeManager.baseConfig.extraSpecialArgs`
These herein are needed for ./../../home/ modules' parameters
*/
extraSpecialArgs = {
inherit inputs rootPath;
libreoffice-postscript = inputs.libreoffice-postscript.legacyPackages.${system};

inherit (inputs.nixvim.legacyPackages.${system}) makeNixvim;
haskellPackages = inputs.ghc-nixpkgs-unstable.legacyPackages.${system}.haskell.packages.ghc965;
ghc-nixpkgs-unstable = inputs.ghc-nixpkgs-unstable.legacyPackages.${system};
unstable = inputs.unstable.legacyPackages.${system};
emacs = if isLinux && isAarch64
then inputs.emacs-overlay-cached.packages.${system}.emacs-unstable-nox
else inputs.emacs-overlay.packages.${system}.emacs-unstable;
Expand Down
1 change: 1 addition & 0 deletions flake/builders/mkNixOnDroid.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ inputs.nix-on-droid.lib.nixOnDroidConfiguration {
extraSpecialArgs = {
inherit inputs rootPath;
unstable = inputs.unstable.legacyPackages.${system};
inherit (inputs.nixvim.legacyPackages.${system}) makeNixvim;
emacs = if isLinux && isAarch64
then inputs.emacs-overlay-cached.packages.${system}.emacs-unstable-nox
else inputs.emacs-overlay.packages.${system}.emacs-unstable;
Expand Down
1 change: 1 addition & 0 deletions flake/builders/mkNixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ inputs.nixpkgs.lib.nixosSystem {
*/
specialArgs = {
inherit inputs rootPath;
inherit (inputs.nixvim.legacyPackages.${system}) makeNixvim;
# NOTE one can alternatively also just (with only inherit inputs;) use in the downstream nix file then: inputs.unstable.legacyPackages.${pkgs.system};
unstable = inputs.unstable.legacyPackages.${system};
emacs = if isLinux && isAarch64
Expand Down
81 changes: 33 additions & 48 deletions home/base/general.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Original author's home'nix files are always prefixed with `{ config, lib, pkgs,
Parameter `[inputs]` here is a deviation from the orinal author's intent (doing that via overlay) and should maybe be fixed
For `[inputs]` parameter determine a solution (./../../nixos/programs/docker.nix also has the issue yet)
*/
{ config, lib, pkgs, inputs, ... }:
{ config, lib, pkgs, inputs, unstable, ... }:
let
inherit (lib)
attrValues
Expand All @@ -18,7 +18,7 @@ Attribute `system` here is determined that way (`inherit (pkgs.stdenv.hostPlatfo
If I want to rid overlays I might have to find a way with less potentially bad implications, IDK are there any ?
*/
inherit (pkgs.stdenv.hostPlatform) system;
#inherit (pkgs.stdenv.hostPlatform) system;
cfg = config.custom.base.general;
localeGerman = "de_DE.UTF-8";
localeEnglish = "en_US.UTF-8";
Expand All @@ -31,7 +31,7 @@ in
enable = mkEnableOption "basic config" // { default = true; };

lightWeight =
mkEnableOption "light weight config for low performance hosts";
mkEnableOption "light weight config for low performance hosts" // { default = false; };

wsl = mkEnableOption "config for NixOS-WSL instances";

Expand All @@ -49,7 +49,7 @@ in
###### implementation

config = mkIf cfg.enable (mkMerge [
(mkIf (!cfg.termux) {
{
custom.programs = {
emacs-novelist.enable = true;
emacs-nano.enable = true;
Expand All @@ -58,7 +58,8 @@ in
nix-index.enable = true;
neovim = {
enable = true;
lightWeight = false; # FIXME Remove this line, only for testing if build works on nix-on-droid
# not inherit not same attr
lightWeight = cfg.lightWeight;
};
};

Expand Down Expand Up @@ -143,7 +144,7 @@ in
;

inherit
(inputs.unstable.legacyPackages.${system})
(unstable)
eza
yazi
;
Expand All @@ -159,6 +160,7 @@ in
];
PAGER = "${pkgs.less}/bin/less";
SHELL = "bash";
# TODO how does that interfere with same attr in neovim.nix
EDITOR = "vi";
VISUAL = "vi";
# (ft-man-plugin),
Expand All @@ -169,13 +171,37 @@ in
# export MANPAGER='nvim -u NONE -i NONE "+runtime plugin/man.lua" -c "Man"''!'' -o -'
#working#MANPAGER = "${config.custom.programs.neovim.finalPackage}/bin/nvim -u NONE -i NONE '+runtime plugin/man.lua' -c Man! -o -";
};

};
}

{
home.stateVersion = "24.05";
}

{
programs.fzf.enable = true;

# FIXME: set to sd-switch once it works for krypton, https://home-manager-options.extranix.com/?query=systemd.user.startServices&release=release-24.05
systemd.user.startServices = "legacy";
}

(mkIf (!cfg.minimal) {
custom = {
misc.util-bins.enable = true;

# see ./home/programs
programs = {
git.enable = true;
nnn.enable = true;
rsync.enable = true;
ssh = {
enable = true;
# modules = [ "vcs" ];
};
};
};

programs.home-manager.enable = true;
})

(mkIf cfg.wsl {
Expand All @@ -187,30 +213,10 @@ in
# programs.starship.enable = true; # long lines are distorted
})

{
home.stateVersion = "24.05";
}

(mkIf cfg.termux {
custom = {
base.general = {
lightWeight = true;
minimal = true;
};
programs.emacs-novelist.enable = true;
};
})

(mkIf (!cfg.lightWeight) {
custom.programs = {
tmux.enable = true;
emacs.enable = true;
# emacs-novelist.enable = true;
#emacs-nano.enable = true;
neovim = {
enable = true;
lightWeight = false;
};
};

home.packages = attrValues {
Expand All @@ -228,26 +234,5 @@ in
;
};
})

(mkIf (!cfg.minimal) {
custom = {
misc.util-bins.enable = true;

# see ./home/programs
programs = {
git.enable = true;
nnn.enable = true;
rsync.enable = true;
ssh = {
enable = true;
# modules = [ "vcs" ];
};
};
};

programs = {
home-manager.enable = true;
};
})
]);
}
6 changes: 3 additions & 3 deletions home/programs/arbtt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Original author's home'nix files are always prefixed with `{ config, lib, pkgs,
For `[haskellPackages]` parameter determine a solution (./../../nixos/programs/docker.nix also has the issue yet)
*/
{ config, lib, pkgs, /*haskellPackages,*/ inputs, ... }:
{ config, lib, pkgs, haskellPackages, inputs, ... }:

let
inherit (lib)
Expand Down Expand Up @@ -37,7 +37,7 @@ in
config = mkIf cfg.enable {
# FIXME https://github.com/toonn/nix-config/blob/master/home/home.nix
home.packages = attrValues {
inherit (inputs.ghc-nixpkgs-unstable.legacyPackages.${system}.haskell.packages.ghc965)
inherit (haskellPackages)
arbtt
;
};
Expand All @@ -51,7 +51,7 @@ in
let
path = builtins.concatStringsSep ":"
(map (p: "${lib.getBin p}/bin")
(attrValues { inherit (inputs.ghc-nixpkgs-unstable.legacyPackages.${system}.haskell.packages.ghc965) arbtt; inherit (pkgs) coreutils; } # with pkgs; []
(attrValues { inherit (haskellPackages) arbtt; inherit (pkgs) coreutils; } # with pkgs; []
)
);
in
Expand Down
7 changes: 4 additions & 3 deletions home/programs/hledger.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
Original author's home'nix files are always prefixed with `{ config, lib, pkgs, ... }:` header
For `[haskellPackages]` parameter determine a solution (./../../nixos/programs/docker.nix also has the issue yet)
*/
{ config, lib, pkgs, inputs, ... }:
{ config, lib, pkgs, inputs, ghc-nixpkgs-unstable, ... }:

let
inherit (lib)
Expand All @@ -17,7 +18,7 @@ let
inherit (pkgs.stdenv) isLinux isx86_64;

inherit
(inputs.ghc-nixpkgs-unstable.legacyPackages.${system})
(ghc-nixpkgs-unstable)
hledger
hledger-utils
hledger-interest
Expand All @@ -30,7 +31,7 @@ Attribute `system` here is determined that way (`inherit (pkgs.stdenv.hostPlatfo
If I want to rid overlays I might have to find a way with less potentially bad implications, IDK are there any ?
*/
inherit (pkgs.stdenv.hostPlatform) system;
# inherit (pkgs.stdenv.hostPlatform) system;

cfg = config.custom.programs.hledger;
in
Expand Down
10 changes: 5 additions & 5 deletions home/programs/neovim.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, lib, pkgs, rootPath, inputs, ... }:
{ config, lib, pkgs, rootPath, inputs, unstable, makeNixvim, ... }:

let
inherit (lib)
Expand All @@ -19,7 +19,7 @@ let
# version = "2023-20-10";
# };

pluggo = pname: inputs.unstable.legacyPackages.${system}.vimUtils.buildVimPlugin { inherit pname; src = inputs."${pname}"; version = "0.1"; };
pluggo = pname: unstable.vimUtils.buildVimPlugin { inherit pname; src = inputs."${pname}"; version = "0.1"; };
/*extraConfig = ''
if filereadable($HOME . "/.vimrc")
source ~/.vimrc
Expand Down Expand Up @@ -354,7 +354,7 @@ in
enable = mkEnableOption "neovim config";

lightWeight =
mkEnableOption "light weight config for low performance hosts" // { default = true; };
mkEnableOption "light weight neovim (vi) config for low performance hosts" // { default = true; };

#lightweight = mkEnableOption "light weight config for low performance hosts";
minimalPackage = mkOption {
Expand Down Expand Up @@ -385,7 +385,7 @@ in
config = mkIf cfg.enable (mkMerge [
{
# FIXME add nvim-lsp as in https://github.com/nix-community/nixd/blob/main/nixd/docs/editors/nvim-lsp.nix
custom.programs.neovim.minimalPackage = inputs.nixvim.legacyPackages."${system}".makeNixvim {
custom.programs.neovim.minimalPackage = makeNixvim {
enableMan = false;
colorschemes.gruvbox.enable = true;
extraPlugins = builtins.attrValues {
Expand Down Expand Up @@ -800,7 +800,7 @@ in

(mkIf (!cfg.lightWeight) {
# inputs.nixvim.legacyPackages."${system}".makeNixvim configuration;
custom.programs.neovim.finalPackage = inputs.nixvim.legacyPackages."${system}".makeNixvim configuration;
custom.programs.neovim.finalPackage = makeNixvim configuration;

home.packages = let inherit (config.custom.programs.neovim) finalPackage; in [
finalPackage
Expand Down
21 changes: 13 additions & 8 deletions lib/common-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ _:

{ lib, pkgs, homeModules ? [ ], inputs, rootPath, ... }:
let
inherit (pkgs.stdenv) isLinux isAarch64
inherit (pkgs.stdenv) isLinux isAarch64;
inherit (inputs.unstable.legacyPackages.${pkgs.system}.pkgs.nixVersions) nix_2_20
; in
{
/**
Expand All @@ -16,13 +17,17 @@ see also ./../flake/builders/mkHome.nix `homeManagerConfiguration.extraSpecialAr
*/
extraSpecialArgs = {
inherit inputs rootPath;
emacs = if isLinux && isAarch64
then inputs.emacs-overlay-cached.packages.${pkgs.system}.emacs-unstable-nox
else inputs.emacs-overlay.packages.${pkgs.system}.emacs-unstable;
inherit (inputs.nixvim.legacyPackages.${pkgs.system}) makeNixvim;
unstable = inputs.unstable.legacyPackages.${pkgs.system};
haskellPackages = inputs.ghc-nixpkgs-unstable.legacyPackages.${pkgs.system}.haskell.packages.ghc965;
ghc-nixpkgs-unstable = inputs.ghc-nixpkgs-unstable.legacyPackages.${pkgs.system};
emacs = if isLinux && isAarch64
then inputs.emacs-overlay-cached.packages.${pkgs.system}.emacs-unstable-nox
else inputs.emacs-overlay.packages.${pkgs.system}.emacs-unstable;

emacsWithPackagesFromUsePackage = if isLinux && isAarch64
then inputs.emacs-overlay-cached.lib.${pkgs.system}.emacsWithPackagesFromUsePackage
else inputs.emacs-overlay.lib.${pkgs.system}.emacsWithPackagesFromUsePackage;
emacsWithPackagesFromUsePackage = if isLinux && isAarch64
then inputs.emacs-overlay-cached.lib.${pkgs.system}.emacsWithPackagesFromUsePackage
else inputs.emacs-overlay.lib.${pkgs.system}.emacsWithPackagesFromUsePackage;
};
sharedModules = homeModules;
useGlobalPkgs = true; # disables options nixpkgs.*
Expand Down Expand Up @@ -78,7 +83,7 @@ see also ./../flake/builders/mkHome.nix `homeManagerConfiguration.extraSpecialAr
};


package = pkgs.nixVersions.nix_2_20;
package = nix_2_20;
# until fixed: https://discourse.nixos.org/t/need-help-with-this-git-related-flake-update-error/50538/7

# https://discourse.nixos.org/t/flake-registry-set-to-a-store-path-keeps-copying/44613
Expand Down
28 changes: 20 additions & 8 deletions nixos/wsl/usbip.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ in

config = mkIf (cfg.enable) {

environment.systemPackages = [
pkgs.linuxPackages.usbip
pkgs.usbutils.out
];
environment.systemPackages = builtins.attrValues {
inherit
(pkgs.linuxPackages)
usbip
;
inherit
(pkgs.usbutils)
out
;
};

services.udev.enable = true;

Expand All @@ -60,10 +66,16 @@ in
after = [ "wsl-vpnkit.target" ];

scriptArgs = "%i";
path = with pkgs; [
iproute2
linuxPackages.usbip
];
path = builtins.attrValues {
inherit
(pkgs)
iproute2
;
inherit
(pkgs.linuxPackages)
usbip
;
};

script = ''
busid="$1"
Expand Down
Loading

0 comments on commit ad8a850

Please sign in to comment.