-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
263 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters