Document not found (404)
+This URL is invalid, sorry. Please use the navigation bar or search to continue.
+ +diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 00000000..f1731109 --- /dev/null +++ b/.nojekyll @@ -0,0 +1 @@ +This file makes sure that Github Pages doesn't process mdBook's output. diff --git a/404.html b/404.html new file mode 100644 index 00000000..befb2962 --- /dev/null +++ b/404.html @@ -0,0 +1,216 @@ + + +
+ + +This URL is invalid, sorry. Please use the navigation bar or search to continue.
+ +In this repo, each flake's README.md
assumes that the directory of its flake.nix
is your current working directory in a terminal.
To de-duplicate the docs, one of the top sections of each README.md
here contains a Prerequisites
section. This section provides the links to other sections that possibly contain the relevant docs. Sometimes, you'll need to traverse multiple Prerequisites
before you achieve the relevant docs.
I inserted a number of binary caches into nixConfig
attribute of each flake.nix
.
+These caches should accelerate builds.
+You can add an accept-flake-config to your nix.conf.
Sometimes, I put dev tools into a nix-dev
directory.
+Then, I enter a devshell as follows.
nix develop nix-dev/
+
+All flakes in this repo access some other flakes from this repo via GitHub
URLs.
+Let's consider two flakes from this repo, A
and B
, where A
is in inputs
of B
.
+If I change the flake A
, I:
A
changes to GitHub.flake.lock
of B
.Whenever there's a push to the remote GitHub
repo, B
's flake.lock
is updated by a GitHub Action
.
+That's why, if that action works, there's no need to commit and push flake.lock
changes.
+After an update is complete, it's necessary to rebase local changes onto remote changes.
+However, sometimes, there are local uncommitted changes already.
+These changes should be git stash
ed before doing git rebase
.
+After rebasing, they can be git stash pop
ped to continue the work.
Thus, the process is as follows:
+# can be omitted in case of automatic fetches
+git fetch
+git rebase --autostash
+git push
+
+Each derivation that evaluates to an executable should have these attributes:
+meta.description
+CommonMark
meta.longDescription
+CommonMark
man
pages for executableslongDescription
should be recognizable by pandoc
+Templates provide extensive information about setting up development environment and packaging Haskell apps.
+ +ghcid is a Very low feature GHCi based IDE
.
+It can be used to re-run a function in a given file on changes in a given directory.
+This template provides a sample configuration for this tool in the .ghcid
file.
hpack translates package.yaml
into .cabal.
Uses haskell4nix.
+Stack support Nix integration.
+Stack uses nix-shell.
+The name of the file providing a Nix shell can be customized in stack.yaml
.
Here's the format of that file - docs.
+The shell file can import the contents of flake.nix
via flake-compat.
flake.nix
provides an output stack-shell.${system} = {version}: ...
.
stack.nix
imports flake.nix
and provides a shell.
devShells.default = pkgs.mkShell {
+ buildInputs = [ packageExe ];
+ shellHook = ''
+ source ${packageExe}/share/bash-completion/completions/${packageExecutableName}
+ '';
+ };
+
+Sometimes, HLS
finds errors in code despite cabal build
running successfully.
+If you use VS Code
, find Outputs
of Haskell Language Server
and determine the cache directory for a project.
It should have approximately this form: /home/<user name>/.cache/hie-bios/dist-<project-name>-<something>
.
+Remove it and restart HLS
.
Install Nix (Single-user installation)
+sh <(curl -L https://nixos.org/nix/install) --no-daemon
+
+Enable flakes
+Set show-trace = true
(doc) to see more complete error messages.
Sometimes, when you enter a devshell (e.g., nix develop
) or run a default package of a flake, you may see:
y
(the simplest way)This is a tool for running scripts in .envrc
files when you enter a directory containing such file.
+One of its usages with flakes is to automatically build, cache, and enter a devshell when you enter that flake's directory in a terminal.
+See Direnv integration
direnv
- src
+Install the binary
+nix profile install nixpkgs#direnv
+
+Hook into your devshell
+When you see direnv
errors, run the suggested commands
Nix
language
+
+I added bookmarks for search engines in my browser, like described here.
+Docs are usually left as comments in Nix
code. You can find an attribute in nix-repl and look up its comments in a file at a given position.
nix repl
+nix-repl> :lf nixpkgs
+nix-repl> legacyPackages.x86_64-linux.lib.lists.singleton
+«lambda @ /nix/store/24akvz6idhp4lxxvhbfxxq84py30v6bw-source/lib/lists.nix:23:15»
+
+Sometimes, you may evaluate a description
or a longDescription
of a derivation:
nix-repl> legacyPackages.x86_64-linux.coreutils.meta.longDescription
+"The GNU Core Utilities are the basic file, shell and text manipulation\nutilities of the GNU operating system. These are the core utilities which\nare expected to exist on every operating system.\n"
+
+Learn about a command:
+nix help command
+
+Search for a package description:
+nix edit nixpkgs#coreutils
+
+If a flake.nix
contains a valid output templates
, these templates can be listed.
+List flake outputs and search for templates
in this (flakes
) repository:
nix flake show | grep template
+└───templates
+evaluating '' ├───codium-generic: template: `VSCodium` with extensions and executables
+ ├───codium-haskell: template: `VSCodium` with extensions and executables for `Haskell`. Shows 5 ways to run a `Haskell` app.
+evaluating '' ├───codium-haskell-simple: template: `VSCodium` with extensions and executables for `Haskell`.
+evaluating '' ├───codium-python: template: `VSCodium` with extensions and executables for `Python`.
+ └───haskell-minimal: template: Minimal flake for a `Haskell` package development.
+
+Two ways of copying from templates:
+ +If you notice that nix flake init
, nix flake new
, etc. give you an old version of a template, run nix flake lock
on that template. This action will force nix
to update the cached version of the template somewhere in ~/.cache/nix
. - src
Templates can be accessed in Nix store via nix repl
:
nix repl
+nix-repl> :lf .
+nix-repl> templates.<TAB>
+nix-repl> templates.codium-generic.path
+/nix/store/j3kx4dk567y483pvszr2w8ghnkxich3d-source/templates/codium/generic
+
+Templates may contain arbitrary files. This feature enables the following assembly:
+nix flake new flake-1 -t flake1
+nix flake new flake-2 -t flake2
+nix flake new flake-3 -t flake3
+cp flake-1/file1 flake-3
+cp flake-2/file{2,3} flake-3
+
+What are flakes? How to enable flakes? - wiki
+Nix manual answers the following questions:
+Nix
store pathderivation
can become an executable, and that executable can be used in build scripts of other derivationsflake.lock
is usedinputs
and outputs
.inputs
and outputs
have specifications described in Nix manual.outputs
?outputs
? (described at the bottom)nixConfig
nix flake show
nix flake metadata
nix repl
+nix-repl> :lf nixpkgs
- load flake nixpkgs
derivation
s used to build a specific derivation
?
+nix show-derivation
nix shell
nix profile
nixpkgs
to a specific commit SHA?
+nix registry
How to add a flake to a project?
+git
to track flake files. So, adding a flake.nix
to a project requires the following steps:
+git init
- initialize a git
repositoryflake.nix
in some way (copy the existing flake.nix
, nix flake init
, etc.)git add flake.nix
flake.lock
in some way (copy the relevant existing flake.lock
, generate a new one via nix flake update
, etc.)git add flake.lock
git commit
these filesHow to use the same flake inputs in all projects?
+ +How to bring any files into a flake?
+git update-index --assume-unchanged <file>
for each <file>
.How to enable a specific version of nix
on my system? Approximately so:
nix registry remove nix
+nix registry add nix github:NixOS/nix/4bf70b74a78bf10f3f19ed122ae7377963e14003
+nix profile install nix --priority 4
+
+How to pin nixpkgs
?
When should I use overlays over nixpkgs
? - You shouldn't
How to convert an exising project to flakes? - tutorial
+How to use a .gitignore
d file inside a flake?
build with --impure
zxcTest = prev.writeText "zxcTest" (builtins.readFile /home/name_snrl/nixos-configuration/<fileFromIgnore>);
+
+Provide it in inputs. Inputs accept arbitrary files. Make links follow the format of flake inputs
+How to disable querying remote binary caches?
+nix run <installable> --no-substitute
pkgs.mkShell
+3. devshell
+4. Add environment variables if necessary. E.g., using Nix store paths post
+5. Symlink a path from Nix store to make files available to NodeJS
- NixOS: The Ultimate Dev Environment?GitHub Actions
Run a binary from nixpkgs
:
nix run nixpkgs#nixpkgs-fmt -- hello-flake/flake.nix
+
+What is expression
, closure
, derivation
?
How to get a path of a derivation in store in a .nix
file?: ${drv}
There are phases
+ +When derivations are built, they may produce executables. Locations of these executables are determined by bash scripts. If you make a derivation you can use buildInputs
to specify the derivations you'd like to be accessible during in scripts during phases
or in a shellHook
How to access a $out
folder of a derivation drv
?
${drv.out}
;Programs can be specified in buildInputs
or called by name {pkgs.hello}/bin/hello
How to wrap an executable to run it with flags?
+pkgs.runCommand
in Wrapping PackagesHow to rename an executable and supply runtime dependencies?
+wrapProgram
provided by pkgs.makeBinaryWrapper
(docs, src).hello =
+pkgs.symlinkJoin {
+ name = "hello";
+ paths = [ hello ];
+ buildInputs = [ pkgs.makeWrapper ];
+ postBuild = ''
+ wrapProgram $out/bin/hello \
+ --set PATH ${
+ pkgs.lib.makeBinPath [
+ pkgs.cowsay
+ ]
+ }
+ '';
+};
+
+How to escape a shell/bash command?
+2. pkgs.lib.escapeShellArg
How to see binaries that a package provides?
+2. find $(nix build nixpkgs#hello --no-link --print-out-paths)/bin -mindepth 1
It's possible to use nix
commands inside scripts
nix-instantiate --eval --strict -E "import ./settings.nix"
- print contents of a nix filenixpkgs
: nix run ${pkgs}#nixpkgs-fmt $nix_path
How to package a script? +2. pkgs.writeScriptBin
+How to remove build deps from runtime deps?
+How to use parallel builds? - docs
+flake-compat
to create default.nix
and shell.nix
nixpkgs.lib
$ nix repl
+nix-repl> :lf nixpkgs
+nix-repl> lib.or true false
+
+Symlinked things cannot be written or opened. They should first be removed - src
+pkgs.dockerTools.buildLayeredImage
- build a docker image
config.Entrypoint = [ command ]
. No need for bash
docker inspect
the imageSee Haskell
+This is not a problem. Just read the text and answer. When asked like:
+do you want to allow configuration setting 'extra-trusted-substituters' to be set to 'https://haskell-language-server.cachix.org https://nix-community.cachix.org https://cache.iog.io https://deemp.cachix.org' (y/N)?
+
+answer y
.
And then, when asked
+do you want to permanently mark this value as trusted (y/N)?
+
+answer y
again. This is to let you use the binary caches listed by the flake.
To provide binary caches, flake.nix
files specify nixConfig.extra-trusted-substituters
. If you try, e.g., nix develop
, and Nix
unsuccessfully tries to download from a cache several times, this cache has probably failed. Comment out the lines containing its URL
address in extra-trusted-substituters
.
Repair a derivation - manual
+Alternative steps:
+flake.nix
flake.nix
by . name your-corrupt-derivation
packages.default = your-corrupt-derivation
in this flake.nix
nix store repair .#
+.#
denotes an installableSee Locales
+ +Install Nix (Single-user installation)
+sh <(curl -L https://nixos.org/nix/install) --no-daemon
+
+Enable flakes
+Set show-trace = true
(doc) to see more complete error messages.
Sometimes, when you enter a devshell (e.g., nix develop
) or run a default package of a flake, you may see:
y
(the simplest way)This is a tool for running scripts in .envrc
files when you enter a directory containing such file.
+One of its usages with flakes is to automatically build, cache, and enter a devshell when you enter that flake's directory in a terminal.
+See Direnv integration
direnv
- src
+Install the binary
+nix profile install nixpkgs#direnv
+
+Hook into your devshell
+When you see direnv
errors, run the suggested commands