mirror of
https://codeberg.org/mhwombat/nix-book.git
synced 2026-01-25 16:07:13 +08:00
initial commit
This commit is contained in:
parent
7761303cd4
commit
7ff82d6fb6
4 changed files with 50 additions and 0 deletions
8
source/recipes/python-nixpkg/shell/Main.py
Normal file
8
source/recipes/python-nixpkg/shell/Main.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
from html_sanitizer import Sanitizer
|
||||
sanitizer = Sanitizer() # default configuration
|
||||
|
||||
original='<span style="font-weight:bold">some text</span>'
|
||||
print('original: ', original)
|
||||
|
||||
sanitized=sanitizer.sanitize(original)
|
||||
print('sanitized: ', sanitized)
|
||||
24
source/recipes/python-nixpkg/shell/main.adoc0
Normal file
24
source/recipes/python-nixpkg/shell/main.adoc0
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
= In `shell.nix`
|
||||
|
||||
[source,nix,linenums]
|
||||
.shell.nix
|
||||
....
|
||||
include::shell.nix[]
|
||||
....
|
||||
|
||||
Here's a short Python program that uses it.
|
||||
|
||||
[source,python,linenums]
|
||||
.Main.hs
|
||||
....
|
||||
include::Main.py[]
|
||||
....
|
||||
|
||||
Here's a demonstration using the program.
|
||||
|
||||
....
|
||||
$# echo '$ nix-shell'
|
||||
$# nix-shell --run bash <<EOL
|
||||
$ python Main.py
|
||||
$# EOL
|
||||
....
|
||||
9
source/recipes/python-nixpkg/shell/shell.nix
Normal file
9
source/recipes/python-nixpkg/shell/shell.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
with (import <nixpkgs> {});
|
||||
let
|
||||
customPython = python3.withPackages (ps: with ps; [ html_sanitizer ]);
|
||||
in
|
||||
mkShell {
|
||||
buildInputs = [
|
||||
customPython
|
||||
];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue