diff --git a/docs/org/homeProfiles.org b/docs/org/homeProfiles.org index 7796c37..65e587a 100644 --- a/docs/org/homeProfiles.org +++ b/docs/org/homeProfiles.org @@ -1,6 +1,6 @@ :PROPERTIES: :header-args: :noweb tangle :comments noweb :exports both -:PRJ-DIR: ../../nixos/homeProfiles +:PRJ-DIR: ../../units/nixos/homeProfiles :ID: 6bb7d46d-7358-4110-a848-f68fffda5b4d :END: #+TITLE: homeProfiles diff --git a/docs/org/loaders.org b/docs/org/loaders.org new file mode 100644 index 0000000..23bc1fc --- /dev/null +++ b/docs/org/loaders.org @@ -0,0 +1,108 @@ +:PROPERTIES: +:ID: da553274-7bc3-4ce0-a314-89a0bfb87a4a +:header-args: :noweb tangle :comments noweb :exports both +:PRJ-DIR: ../.. +:EXP-DIR: ../../examples +:END: +#+TITLE: loaders +#+AUTHOR: GuangTao Zhang +#+EMAIL: gtrunsec@hardenedlinux.org +#+DATE: 2023-11-19 Sun 15:16 + + +#+begin_quote +Please note that in Pops, the outputs/results should not be directly printed, but instead, they wll be exported through the exports property under the pop object. +#+end_quote + + +* packages +:PROPERTIES: +:CODE-DIR: ../../src/pops +:END: + +- function: ~omnibus.pops.pacakges~ + +that function is responsible for loading packages in a tree structure and nixpkgs.callPackage <>automatically. + +#+begin_src nix :tangle (concat (org-entry-get (point) "CODE-DIR" t) "/packages.nix") +{ super, root }: +load: +let + inherit + (root.errors.requiredInputs load.inputs "omnibus.pops.packages" [ "nixpkgs" ]) + nixpkgs + ; + inherit (nixpkgs) newScope; + inherit (nixpkgs.lib) makeScope; +in +makeScope newScope ( + selfScope: + ((super.load load).addLoadExtender { + load = { + loader = + __inputs__: path: + (selfScope.overrideScope (_: _: { inherit __inputs__; })).callPackage path { }; + transformer = [ (_cursor: dir: if dir ? default then dir.default else dir) ]; + }; + }).addExporters + [ + (POP.extendPop flops.haumea.pops.exporter ( + self: _super: { + exports = { + overlay = + final: prev: + (self.layouts.self.addLoadExtender { + load = { + inputs.inputs.nixpkgs = final; + loader = + __inputs__: path: + (__inputs__.inputs.nixpkgs.extend (_: _: { inherit __inputs__; })).callPackage + path + { }; + }; + }).exports.default; + }; + } + )) + ] +) +#+end_src + +- *pops.packages* have an arg named by anti-namespace of *__inputs__* in the scopePackages, that *__inptus__* can pass all args same as haumea.inputs, such as {super,self, ...} => {__inputs__.self, __inputs__.super, inputs.{...} } + + +** Example + +#+begin_src nix :tangle (concat (org-entry-get nil "EXP-DIR" t) "/packages/default.nix") +{ + omnibus, + inputs, + self, +}: +omnibus.pops.packages { + src = ./__fixture; + inputs = { + nixpkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; + }; +} +# => out.exports { default = {...}, packages = {...}; } +#+end_src + + ++ exports + +#+begin_src nix +nix-repl> :p Flake.examples.packages.exports.default +{ hello1 = «derivation /nix/store/kc6j6vssi60h1yn3kafc7v8ywn1j35lp-example-unfree-package-2.0.drv»; hello2 = «derivation / +nix/store/v0qa0lw6jhzcwj68zz939kn8ixmiabnb-example-unfree-package-3.0.drv»; } +#+end_src + + - default (packageSet) + - overlay + #+begin_src nix :tangle (concat (org-entry-get nil "EXP-DIR" t) "/packagesOverlay.nix") +{ super, omnibus }: +let + nixos-23_05 = omnibus.flake.inputs.nixos-23_05; +in +nixos-23_05.legacyPackages.x86_64-linux.extend super.packages.exports.overlay + #+end_src diff --git a/docs/org/pops-packages.org b/docs/org/pops-packages.org new file mode 100644 index 0000000..bca0cac --- /dev/null +++ b/docs/org/pops-packages.org @@ -0,0 +1,107 @@ +:PROPERTIES: +:ID: f7adb0ad-2cc1-4723-a796-bf608682456a +:header-args: :noweb tangle :comments noweb :exports both +:PRJ-DIR: ../.. +:EXP-DIR: ../../examples +:CODE-DIR: ../../src/pops +:END: +#+TITLE: pops-packages +#+AUTHOR: GuangTao Zhang +#+EMAIL: gtrunsec@hardenedlinux.org +#+DATE: 2023-11-19 Sun 16:25 + + +- function: ~omnibus.pops.pacakges~ is responsible for loading packages in a tree structure then nixpkgs.callPackage with *path* automatically. + + +#+begin_src nix :tangle (concat (org-entry-get nil "CODE-DIR" t) "/packages.nix") +{ super, root }: +load: +let + inherit + (root.errors.requiredInputs load.inputs "omnibus.pops.packages" [ "nixpkgs" ]) + nixpkgs + ; + inherit (nixpkgs) newScope; + inherit (nixpkgs.lib) makeScope; +in +makeScope newScope ( + selfScope: + ((super.load load).addLoadExtender { + load = { + loader = + __inputs__: path: + (selfScope.overrideScope (_: _: { inherit __inputs__; })).callPackage path { }; + transformer = [ (_cursor: dir: if dir ? default then dir.default else dir) ]; + }; + }).addExporters + [ + (POP.extendPop flops.haumea.pops.exporter ( + self: _super: { + exports = { + overlay = + final: prev: + (self.layouts.self.addLoadExtender { + load = { + inputs.inputs.nixpkgs = final; + loader = + __inputs__: path: + (__inputs__.inputs.nixpkgs.extend (_: _: { inherit __inputs__; })).callPackage + path + { }; + }; + }).exports.default; + }; + } + )) + ] +) +#+end_src + +- *pops.packages* have an arg named by anti-namespace of *__inputs__* in the scopePackages, that *__inptus__* can pass all args same as haumea.inputs, such as {super,self, ...} => {__inputs__.self, __inputs__.super, inputs.{...} } + + +** Example + +#+begin_src nix :tangle (concat (org-entry-get nil "EXP-DIR" t) "/packages/default.nix") +{ + omnibus, + inputs, + self, +}: +omnibus.pops.packages { + src = ./__fixture; + inputs = { + nixpkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; + }; +} +# => out.exports { default = {...}, packages = {...}; } +#+end_src + + +#+begin_quote +Please note that in Pops, the outputs/results should not be directly printed, but instead, they wll be exported through the exports property under the pop object. +#+end_quote + + ++ exports + +#+begin_src nix + +# => default (packageSet) +nix-repl> :p Flake.examples.packages.exports.default +{ hello1 = «derivation /nix/store/kc6j6vssi60h1yn3kafc7v8ywn1j35lp-example-unfree-package-2.0.drv»; hello2 = «derivation / +nix/store/v0qa0lw6jhzcwj68zz939kn8ixmiabnb-example-unfree-package-3.0.drv»; } +# => overlay +nix-repl> :p Flake.examples.packages.exports.overlay +«lambda @ /home/guangtao/Dropbox/omnibus/src/pops/packages.nix:27:15» +#+end_src + + - aplly the overlay with nixpkgs + #+begin_src nix :tangle (concat (org-entry-get nil "EXP-DIR" t) "/packagesOverlay.nix") +{ super, omnibus }: +let + nixos-23_05 = omnibus.flake.inputs.nixos-23_05; +in +nixos-23_05.legacyPackages.x86_64-linux.extend super.packages.exports.overlay + #+end_src diff --git a/docs/org/pops.org b/docs/org/pops.org new file mode 100644 index 0000000..3353c10 --- /dev/null +++ b/docs/org/pops.org @@ -0,0 +1,18 @@ +:PROPERTIES: +:ID: da553274-7bc3-4ce0-a314-89a0bfb87a4a +:header-args: :noweb tangle :comments noweb :exports both +:PRJ-DIR: ../.. +:EXP-DIR: ../../examples +:END: +#+TITLE: pops +#+AUTHOR: GuangTao Zhang +#+EMAIL: gtrunsec@hardenedlinux.org +#+DATE: 2023-11-19 Sun 15:16 + +#+begin_quote +Please note that in Pops, the outputs/results should not be directly printed, but instead, they wll be exported through the exports property under the pop object. +#+end_quote + +* Loaders + +- [[id:f7adb0ad-2cc1-4723-a796-bf608682456a][pops-packages]] (loading the packages into nixpkgs from a directory) diff --git a/examples/packages/default.nix b/examples/packages/default.nix index 71342f7..714c517 100644 --- a/examples/packages/default.nix +++ b/examples/packages/default.nix @@ -1,3 +1,4 @@ +# [[file:../../docs/org/pops-packages.org::*Example][Example:1]] { omnibus, inputs, @@ -9,3 +10,5 @@ omnibus.pops.packages { nixpkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; }; } +# => out.exports { default = {...}, packages = {...}; } +# Example:1 ends here diff --git a/examples/packagesOverlay.nix b/examples/packagesOverlay.nix index 8694080..9596709 100644 --- a/examples/packagesOverlay.nix +++ b/examples/packagesOverlay.nix @@ -1,5 +1,7 @@ +# [[file:../docs/org/pops-packages.org::*Example][Example:3]] { super, omnibus }: let nixos-23_05 = omnibus.flake.inputs.nixos-23_05; in nixos-23_05.legacyPackages.x86_64-linux.extend super.packages.exports.overlay +# Example:3 ends here diff --git a/local/lock/flake.lock b/local/lock/flake.lock index fedf2c0..d120339 100644 --- a/local/lock/flake.lock +++ b/local/lock/flake.lock @@ -992,11 +992,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1697635498, - "narHash": "sha256-jWkdNqeSoIVG2o2ajj/93CxCRRrigWmPbBU10woabsU=", + "lastModified": 1700348034, + "narHash": "sha256-j28MwKtP+W8jFi6OHE/8TqhRZr9rIZTJKXxjN58Fc8E=", "owner": "serokell", "repo": "nixfmt", - "rev": "7649a1b5626d87219904350295ca77593aff1349", + "rev": "4ef4c39acd501a9a1b06b3a151b36be5daebcef3", "type": "github" }, "original": { diff --git a/src/pops/packages.nix b/src/pops/packages.nix index 1003996..21a8da3 100644 --- a/src/pops/packages.nix +++ b/src/pops/packages.nix @@ -1,3 +1,4 @@ +# [[id:f7adb0ad-2cc1-4723-a796-bf608682456a][No heading:1]] { super, root }: load: let @@ -9,15 +10,15 @@ let inherit (nixpkgs.lib) makeScope; in makeScope newScope ( - selfScope - ((super.load load).addLoadExtender { - load = { - loader = - __inputs__: path: - (selfScope.overrideScope (_: _: { inherit __inputs__; })).callPackage path { }; - transformer = [ (_cursor: dir: if dir ? default then dir.default else dir) ]; - }; - }).addExporters + selfScope: + ((super.load load).addLoadExtender { + load = { + loader = + __inputs__: path: + (selfScope.overrideScope (_: _: { inherit __inputs__; })).callPackage path { }; + transformer = [ (_cursor: dir: if dir ? default then dir.default else dir) ]; + }; + }).addExporters [ (POP.extendPop flops.haumea.pops.exporter ( self: _super: { @@ -39,3 +40,4 @@ makeScope newScope ( )) ] ) +# No heading:1 ends here diff --git a/units/configs/treefmt.nix b/units/configs/treefmt.nix index 2041541..e300819 100644 --- a/units/configs/treefmt.nix +++ b/units/configs/treefmt.nix @@ -27,6 +27,7 @@ in nix = { includes = [ "*.nix" ]; command = "nixfmt"; + options = [ "--width=80" ]; excludes = [ ]; }; prettier = { diff --git a/units/flake-parts/profiles/process-compose/sqlite-example.nix b/units/flake-parts/profiles/process-compose/sqlite-example.nix index 0d9f521..eebcdd1 100644 --- a/units/flake-parts/profiles/process-compose/sqlite-example.nix +++ b/units/flake-parts/profiles/process-compose/sqlite-example.nix @@ -34,9 +34,7 @@ in # Create .sqlite database from chinook database. sqlite-init.command = '' echo "$(date): Importing Chinook database (${dataFile}) ..." - ${ - lib.getExe pkgs.sqlite - } "${dataFile}" < ${chinookDb}/ChinookDatabase/DataSources/Chinook_Sqlite.sql + ${lib.getExe pkgs.sqlite} "${dataFile}" < ${chinookDb}/ChinookDatabase/DataSources/Chinook_Sqlite.sql echo "$(date): Done." ''; diff --git a/units/nixos/homeProfiles/presets/spell-check.nix b/units/nixos/homeProfiles/presets/spell-check.nix index ed42d8b..8fa7d0a 100644 --- a/units/nixos/homeProfiles/presets/spell-check.nix +++ b/units/nixos/homeProfiles/presets/spell-check.nix @@ -10,12 +10,10 @@ let ); in { - home.file.".config/enchant/enenchant.ordering".source = - pkgs.writeText "enenchant.ordering" - '' - *:${ordering} - en_US:${ordering} - ''; + home.file.".config/enchant/enenchant.ordering".source = pkgs.writeText "enenchant.ordering" '' + *:${ordering} + en_US:${ordering} + ''; home.packages = with pkgs; [ (hunspellWithDicts [ hunspellDicts.en-us ]) (aspellWithDicts ( diff --git a/units/nixos/homeProfiles/shell.nix b/units/nixos/homeProfiles/shell.nix index 3d3721e..0e8439b 100644 --- a/units/nixos/homeProfiles/shell.nix +++ b/units/nixos/homeProfiles/shell.nix @@ -1,4 +1,4 @@ -# [[file:../../../docs/org/homeProfiles.org::*shell][shell:1]] +# [[id:cbe34da3-ffbb-423c-aee4-d0cd71af51e4][shell:1]] { root, self, diff --git a/units/nixos/nixosModules/omnibus/bootstrap/packages.nix b/units/nixos/nixosModules/omnibus/bootstrap/packages.nix index 6aec1cd..7a4668a 100644 --- a/units/nixos/nixosModules/omnibus/bootstrap/packages.nix +++ b/units/nixos/nixosModules/omnibus/bootstrap/packages.nix @@ -34,9 +34,7 @@ in if [ -z "$1" ]; then nix repl --argstr host "$HOST" --argstr flakePath "$PRJ_ROOT" ${./nrepl.nix} else - nix repl --argstr host "$HOST" --argstr flakePath $(readlink -f $1 | sed 's|/flake.nix||') ${ - ./nrepl.nix - } + nix repl --argstr host "$HOST" --argstr flakePath $(readlink -f $1 | sed 's|/flake.nix||') ${./nrepl.nix} fi '') ripgrep diff --git a/units/nixos/nixosModules/omnibus/coding/python.nix b/units/nixos/nixosModules/omnibus/coding/python.nix index 6890a65..171df75 100644 --- a/units/nixos/nixosModules/omnibus/coding/python.nix +++ b/units/nixos/nixosModules/omnibus/coding/python.nix @@ -1,11 +1,7 @@ { options = with lib; { - enableLspBridge = - mkEnableOption - "Enable the language server protocol bridge support"; - enableEmacsEaf = - mkEnableOption - "Enable the Emacs Application Framework support"; + enableLspBridge = mkEnableOption "Enable the language server protocol bridge support"; + enableEmacsEaf = mkEnableOption "Enable the Emacs Application Framework support"; python = mkOption { type = types.package; default = pkgs.python3;