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 5ed771c
Show file tree
Hide file tree
Showing 14 changed files with 155 additions and 84 deletions.
7 changes: 4 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@
});

inherit (nixpkgs.lib) listToAttrs attrValues;
inherit (flakeLib) mkApp mkHome mkNixOnDroid mkNixos mkDevenvJvmLang mkDevenvDeno mkDevenvFlutter mkDevenvOcaml mkDevenvRust mkDevenvMachnix mkDevenvJupyenv mkDevenvRuby mkDevenvHaskell mkDevenvRustWasm32;
inherit (flakeLib) mkApp mkHome mkNixOnDroid mkNixos mkDevenvJvmLang mkDevenvDeno mkDevenvFlutter mkDevenvOcaml mkDevenvRust mkDevenvMachnix mkDevenvJupyenv mkDevenvRuby mkDevenvHaskell mkDevenvRustWasm32 mkDevShellJdk;
# NOTE https://discourse.nixos.org/t/installing-only-a-single-package-from-unstable/5598/30
# and https://discourse.nixos.org/t/add-an-option-to-home-manager-as-a-nixos-module-using-flake/38731/4
# and https://discourse.nixos.org/t/how-do-specialargs-work/50615/4
Expand Down Expand Up @@ -714,7 +714,8 @@
}
)
# AFAIU the pkgs used herein (mkDevenv*) are with the overlays as in flake/nixpkgs.nix etc. applied, also means any derivation defined therein can be used here then, but is a different derivation than i. e. some binary-cached elsewhere, which can lead to subtle differences i. e. (un)expected rebuilds. To use a binary-cached flake define here directly in flake.nix and add overlays when needed only.
(mkDevenvJupyenv system "jupyenv" { })
(mkDevShellJdk system "jdk21" { jdk = pkgs: pkgs.jdk21; })
(mkDevenvJupyenv system "jupyenv" { })
(mkDevenvJvmLang system "jvmlanguages-devenv" { })
(mkDevenvDeno system "deno" { })
(mkDevenvFlutter system "flutter" { })
Expand All @@ -723,7 +724,7 @@
(mkDevenvRuby system "ruby" { })
(mkDevenvRust system "rust" { })
(mkDevenvRustWasm32 system "rustwasm32" { })
(mkDevenvHaskell system "haskell" { })
(mkDevenvHaskell system "haskell" { inherit (specialArgs.${system}) haskellPackages; })

(mkDevenvMachnix system "machnix" { })
#(mkDevenvJulia system "julia" { })
Expand Down
12 changes: 12 additions & 0 deletions flake/builders/mkDevShellJdk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ system, pkgsFor, name, args, ... }:

let
pkgs = pkgsFor.${system};
jdk = args.jdk pkgs;
in

pkgs.mkShell {
inherit name;
buildInputs = [ jdk pkgs.maven ];
JAVA_HOME = jdk;
}
6 changes: 3 additions & 3 deletions flake/builders/mkDevenvHaskell.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{ system, pkgsFor, inputs, specialArgs, name, args, ... }:
{ system, pkgsFor, inputs, name, args, ... }:

let
pkgs = pkgsFor.${system};
inherit (inputs.devenv.lib) mkShell;
inherit (specialArgs.${system}) haskellPackages;
#inherit (specialArgs.${system}) haskellPackages;
in
mkShell rec {
inherit inputs pkgs;
modules = [
({ pkgs, ... }:
let
myHaskellPackages =
haskellPackages.override (old: {
args.haskellPackages.override (old: {
overrides = pkgs.lib.composeExtensions (old.overrides or (_: _: { }))
(hself: hsuper: {
ghc = hsuper.ghc // { withPackages = hsuper.ghc.withHoogle; };
Expand Down
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
1 change: 1 addition & 0 deletions flake/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ in
mkNixos = simpleWrapper ./builders/mkNixos.nix;

mkApp = wrapper ./builders/mkApp.nix;
mkDevShellJdk = wrapper ./builders/mkDevShellJdk.nix;
mkDevenvJvmLang = wrapper ./builders/mkDevenvJvmLang.nix;
mkDevenvDeno = wrapper ./builders/mkDevenvDeno.nix;
mkDevenvFlutter = wrapper ./builders/mkDevenvFlutter.nix;
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
Loading

0 comments on commit 5ed771c

Please sign in to comment.