From 54f4db6d264db48ce2f451ae54ab73fdabbba476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amy=20de=20Buitl=C3=A9ir?= Date: Fri, 5 Sep 2025 19:59:37 +0100 Subject: [PATCH] expanded --- index.html | 259 ++++++------------ source/recipes/devshell/main.adoc | 2 +- .../devshell/non-flake/tempwork/flake.lock | 77 ------ .../devshell/non-flake/tempwork/flake.nix | 27 -- .../recipes/haskell-nixpkg/shebang/main.adoc0 | 13 - source/recipes/remote-git/main.adoc | 16 -- .../haskell-nixpkg/main.adoc0} | 13 + .../haskell-nixpkg}/my-script.sh | 0 source/recipes/shebang/main.adoc0 | 2 + 9 files changed, 98 insertions(+), 311 deletions(-) delete mode 100644 source/recipes/devshell/non-flake/tempwork/flake.lock delete mode 100644 source/recipes/devshell/non-flake/tempwork/flake.nix delete mode 100644 source/recipes/haskell-nixpkg/shebang/main.adoc0 delete mode 100644 source/recipes/remote-git/main.adoc rename source/recipes/{haskell-nixpkg/main.adoc => shebang/haskell-nixpkg/main.adoc0} (76%) rename source/recipes/{haskell-nixpkg/shebang => shebang/haskell-nixpkg}/my-script.sh (100%) diff --git a/index.html b/index.html index 13e3cc3..4226e78 100644 --- a/index.html +++ b/index.html @@ -194,6 +194,8 @@
  • 10.4. Development shells with access to…​ @@ -201,34 +203,27 @@
  • 10.4.1. A top level package from the Nixpkgs/NixOS repo
  • 10.4.2. A flake
  • 10.4.3. A Haskell library package in the nixpkgs repo (without a .cabal file)
  • -
  • 10.4.4. A non-flake package (not in nixpkgs)
  • 10.5. An (old-style) Nix shell with access to a flake
  • -
  • 10.6. Access to a package defined in a remote git repo
  • -
  • 10.7. Access to a Haskell library package in the nixpkgs repo (without a .cabal file) +
  • 10.6. Access to a Haskell package on your local computer
  • -
  • 10.8. Access to a Haskell package on your local computer +
  • 10.7. Access to a Haskell package on your local computer, with inter-dependencies
  • -
  • 10.9. Access to a Haskell package on your local computer, with inter-dependencies +
  • 10.8. Access to a Python library package in the nixpkgs repo (without using a Python builder)
  • -
  • 10.10. Access to a Python library package in the nixpkgs repo (without using a Python builder) +
  • 10.9. Set an environment variable -
  • -
  • 10.11. Set an environment variable -
  • @@ -4222,6 +4217,66 @@ However, you can use any of the flake reference styles defined in +

    10.3.3. Access to a Haskell library package in the nixpkgs repo (without a .cabal file)

    +
    +

    Occasionally you might want to run a short Haskell program that depends on a Haskell library, +but you don’t want to bother writing a cabal file.

    +
    +
    +

    Example: Access the containers package from the haskellPackages set in the nixpkgs repo.

    +
    +
    +

    Unresolved directive in recipes/shebang/haskell-nixpkg/main-generated.adoc - include::shell/main-generated.adoc[leveloffset=+1]

    +
    +
    +

    Unresolved directive in recipes/shebang/haskell-nixpkg/main-generated.adoc - include::shebang/main-generated.adoc[leveloffset=+1]

    +
    + +
    +

    10.3.4. In a Haskell script

    +
    +
    Script
    +
    +
     1
    + 2
    + 3
    + 4
    + 5
    + 6
    + 7
    + 8
    + 9
    +10
    +11
    +12
    +13
    +14
    +15
    #! /usr/bin/env nix-shell
    +#! nix-shell -p "haskellPackages.ghcWithPackages (p: [p.containers])"
    +#! nix-shell -i runghc
    +
    +import Data.Map
    +
    +m :: Map String Int
    +m = fromList [("cats", 3), ("dogs", 2)]
    +
    +main :: IO ()
    +main = do
    +  let cats = findWithDefault 0 "cats" m
    +  let dogs = findWithDefault 0 "dogs" m
    +  let zebras = findWithDefault 0 "zebras" m
    +  print $ "I have " ++ show cats ++ " cats, " ++ show dogs ++ " dogs, and " ++ show zebras ++ " zebras."
    +
    +
    +
    +
    +
    Output
    +
    +
    "I have 3 cats, 2 dogs, and 0 zebras."
    +
    +
    +

    10.4. Development shells with access to…​

    @@ -4506,83 +4561,8 @@ $ runghc Main.hs "I have 3 cats, 2 dogs, and 0 zebras."
    - -
    -

    10.4.4. A non-flake package (not in nixpkgs)

    -
    -
    flake.nix
    -
    -
     1
    - 2
    - 3
    - 4
    - 5
    - 6
    - 7
    - 8
    - 9
    -10
    -11
    -12
    -13
    -14
    -15
    -16
    -17
    -18
    -19
    -20
    -21
    -22
    -23
    -24
    -25
    -26
    -27
    {
    -  inputs = {
    -    nixpkgs.url = "github:NixOS/nixpkgs";
    -    flake-utils.url = "github:numtide/flake-utils";
    -    hello-nix = {
    -      url = "git+https://codeberg.org/mhwombat/hello-nix";
    -      flake = false;
    -    };
    -  };
    -
    -  outputs = { self, nixpkgs, flake-utils, hello-nix }:
    -    flake-utils.lib.eachDefaultSystem (system:
    -      let
    -        pkgs = import nixpkgs { inherit system; };
    -      in
    -      {
    -        devShells = rec {
    -          default = pkgs.mkShell {
    -            shellHook =
    -              ''
    -                PATH=${hello-nix}:$PATH
    -              '';
    -          };
    -        };
    -      }
    -    );
    -}
    -
    -
    -
    -
    -

    Here’s a demonstration using the shell.

    -
    -
    -
    -
    $ hello-nix # this will fail
    -bash: line 20: hello-nix: command not found
    -$ nix develop
    -$ hello-nix
    -Hello from your nix package!
    -
    +

    /// SKIP include::non-flake/main-generated.adoc[leveloffset=+1]

    @@ -4630,97 +4610,22 @@ $ hello-flake Hello from your flake! - -
    -

    10.6. Access to a package defined in a remote git repo

    -

    Ex: Access a package (not a flake) called hello-nix, -which is defined in a remote git repo on codeberg. -To use a package from GitHub, GitLab, or any other public platform, -modify the URL.

    +

    Unresolved directive in recipes/main.adoc - include::remote-git/main.adoc[leveloffset=+1]

    -

    REMOVE ME

    -
    -
    -

    REMOVE ME

    -
    -
    -

    REMOVE ME

    -
    -
    -

    REMOVE ME

    -
    -
    -

    Unresolved directive in recipes/remote-git/main.adoc - include::flake/main-generated.adoc[leveloffset=+1]

    +

    Unresolved directive in recipes/main.adoc - include::haskell-nixpkg/main.adoc[leveloffset=+1]

    -

    10.7. Access to a Haskell library package in the nixpkgs repo (without a .cabal file)

    -
    -

    Occasionally you might want to run a short Haskell program that depends on a Haskell library, -but you don’t want to bother writing a cabal file.

    -
    -
    -

    Example: Access the containers package from the haskellPackages set in the nixpkgs repo.

    -
    -
    -

    Unresolved directive in recipes/haskell-nixpkg/main.adoc - include::shell/main-generated.adoc[leveloffset=+1]

    -
    -
    -

    10.7.1. In a Haskell script

    -
    -
    Script
    -
    -
     1
    - 2
    - 3
    - 4
    - 5
    - 6
    - 7
    - 8
    - 9
    -10
    -11
    -12
    -13
    -14
    -15
    #! /usr/bin/env nix-shell
    -#! nix-shell -p "haskellPackages.ghcWithPackages (p: [p.containers])"
    -#! nix-shell -i runghc
    -
    -import Data.Map
    -
    -m :: Map String Int
    -m = fromList [("cats", 3), ("dogs", 2)]
    -
    -main :: IO ()
    -main = do
    -  let cats = findWithDefault 0 "cats" m
    -  let dogs = findWithDefault 0 "dogs" m
    -  let zebras = findWithDefault 0 "zebras" m
    -  print $ "I have " ++ show cats ++ " cats, " ++ show dogs ++ " dogs, and " ++ show zebras ++ " zebras."
    -
    -
    -
    -
    -
    Output
    -
    -
    "I have 3 cats, 2 dogs, and 0 zebras."
    -
    -
    -
    -
    -
    -

    10.8. Access to a Haskell package on your local computer

    +

    10.6. Access to a Haskell package on your local computer

    Ex: Access three Haskell packages (pandoc-linear-table, pandoc-logic-proof, and pandoc-columns) that are on my hard drive.

    -

    10.8.1. In shell.nix

    +

    10.6.1. In shell.nix

    shell.nix
    @@ -4757,7 +4662,7 @@ mkShell {
    -

    10.9. Access to a Haskell package on your local computer, with inter-dependencies

    +

    10.7. Access to a Haskell package on your local computer, with inter-dependencies

    Ex: Access four Haskell packages (pandoc-linear-table, pandoc-logic-proof, pandoc-columns and pandoc-maths-web) @@ -4765,7 +4670,7 @@ that are on my hard drive. The fourth package depends on the first three to build.

    -

    10.9.1. In shell.nix

    +

    10.7.1. In shell.nix

    shell.nix
    @@ -4812,7 +4717,7 @@ mkShell {
    -

    10.10. Access to a Python library package in the nixpkgs repo (without using a Python builder)

    +

    10.8. Access to a Python library package in the nixpkgs repo (without using a Python builder)

    Occasionally you might want to run a short Python program that depends on a Python library, but you don’t want to bother configuring a builder.

    @@ -4821,7 +4726,7 @@ but you don’t want to bother configuring a builder.

    Example: Access the html_sanitizer package from the python3nnPackages set in the nixpkgs repo.

    -

    10.10.1. In a Python script

    +

    10.8.1. In a Python script

    Script
    @@ -4859,12 +4764,12 @@ sanitized: <strong>some text</strong>
    -

    10.11. Set an environment variable

    +

    10.9. Set an environment variable

    Ex: Set the value of the environment variable FOO to “bar”

    -

    10.11.1. In shell.nix

    +

    10.9.1. In shell.nix

    shell.nix
    @@ -4898,7 +4803,7 @@ mkShell {
    diff --git a/source/recipes/devshell/main.adoc b/source/recipes/devshell/main.adoc index 8494074..8fd0dfc 100644 --- a/source/recipes/devshell/main.adoc +++ b/source/recipes/devshell/main.adoc @@ -6,5 +6,5 @@ include::flake/main-generated.adoc[leveloffset=+1] include::haskell-pkg/main-generated.adoc[leveloffset=+1] -include::non-flake/main-generated.adoc[leveloffset=+1] +/// SKIP include::non-flake/main-generated.adoc[leveloffset=+1] diff --git a/source/recipes/devshell/non-flake/tempwork/flake.lock b/source/recipes/devshell/non-flake/tempwork/flake.lock deleted file mode 100644 index 25e25ef..0000000 --- a/source/recipes/devshell/non-flake/tempwork/flake.lock +++ /dev/null @@ -1,77 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "hello-nix": { - "flake": false, - "locked": { - "lastModified": 1676213208, - "narHash": "sha256-Zds5C+f5sA3w+j85EsAQjte0zeHqubMVPGYn5lGwATo=", - "ref": "refs/heads/main", - "rev": "aa2c87f8b89578b069b09fdb2be30a0c9d8a77d8", - "revCount": 4, - "type": "git", - "url": "https://codeberg.org/mhwombat/hello-nix" - }, - "original": { - "type": "git", - "url": "https://codeberg.org/mhwombat/hello-nix" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1757096966, - "narHash": "sha256-nJpPWCFbc5/u0VIoSHT350FEwPS5pwiRfyZBbZA3Kgg=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "6eb784fb955ab56952e6eeb01f3e64a79933e2b5", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "hello-nix": "hello-nix", - "nixpkgs": "nixpkgs" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/source/recipes/devshell/non-flake/tempwork/flake.nix b/source/recipes/devshell/non-flake/tempwork/flake.nix deleted file mode 100644 index 560bc6e..0000000 --- a/source/recipes/devshell/non-flake/tempwork/flake.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs"; - flake-utils.url = "github:numtide/flake-utils"; - hello-nix = { - url = "git+https://codeberg.org/mhwombat/hello-nix"; - flake = false; - }; - }; - - outputs = { self, nixpkgs, flake-utils, hello-nix }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - in - { - devShells = rec { - default = pkgs.mkShell { - shellHook = - '' - PATH=${hello-nix}:$PATH - ''; - }; - }; - } - ); -} diff --git a/source/recipes/haskell-nixpkg/shebang/main.adoc0 b/source/recipes/haskell-nixpkg/shebang/main.adoc0 deleted file mode 100644 index 5bbab81..0000000 --- a/source/recipes/haskell-nixpkg/shebang/main.adoc0 +++ /dev/null @@ -1,13 +0,0 @@ -= In a Haskell script - -[source,haskell,linenums] -.Script -.... -include::my-script.sh[] -.... - -.Output -.... -$# ./my-script.sh -.... - diff --git a/source/recipes/remote-git/main.adoc b/source/recipes/remote-git/main.adoc deleted file mode 100644 index 58efbd6..0000000 --- a/source/recipes/remote-git/main.adoc +++ /dev/null @@ -1,16 +0,0 @@ -= Access to a package defined in a remote git repo - -Ex: Access a package (not a flake) called `hello-nix`, -which is defined in a remote git repo on codeberg. -To use a package from GitHub, GitLab, or any other public platform, -modify the URL. - -REMOVE ME - -REMOVE ME - -REMOVE ME - -REMOVE ME - -include::flake/main-generated.adoc[leveloffset=+1] diff --git a/source/recipes/haskell-nixpkg/main.adoc b/source/recipes/shebang/haskell-nixpkg/main.adoc0 similarity index 76% rename from source/recipes/haskell-nixpkg/main.adoc rename to source/recipes/shebang/haskell-nixpkg/main.adoc0 index ecd84ee..66953bb 100644 --- a/source/recipes/haskell-nixpkg/main.adoc +++ b/source/recipes/shebang/haskell-nixpkg/main.adoc0 @@ -9,3 +9,16 @@ include::shell/main-generated.adoc[leveloffset=+1] include::shebang/main-generated.adoc[leveloffset=+1] += In a Haskell script + +[source,haskell,linenums] +.Script +.... +include::my-script.sh[] +.... + +.Output +.... +$# ./my-script.sh +.... + diff --git a/source/recipes/haskell-nixpkg/shebang/my-script.sh b/source/recipes/shebang/haskell-nixpkg/my-script.sh similarity index 100% rename from source/recipes/haskell-nixpkg/shebang/my-script.sh rename to source/recipes/shebang/haskell-nixpkg/my-script.sh diff --git a/source/recipes/shebang/main.adoc0 b/source/recipes/shebang/main.adoc0 index 3c2157b..4fee2ce 100644 --- a/source/recipes/shebang/main.adoc0 +++ b/source/recipes/shebang/main.adoc0 @@ -37,3 +37,5 @@ $# cat run-flake.sh .... $# ./run-flake.sh .... + +include::haskell-nixpkg/main-generated.adoc[leveloffset=+1]