Merge remote-tracking branch 'upstream/master' into aj-rust-custom-target
This commit is contained in:
commit
8ddf5c6907
|
@ -76,10 +76,12 @@ trim_trailing_whitespace = unset
|
|||
|
||||
[pkgs/build-support/dotnetenv/Wrapper/**]
|
||||
end_of_line = unset
|
||||
indent_style = unset
|
||||
insert_final_newline = unset
|
||||
trim_trailing_whitespace = unset
|
||||
|
||||
[pkgs/build-support/upstream-updater/**]
|
||||
indent_style = unset
|
||||
trim_trailing_whitespace = unset
|
||||
|
||||
[pkgs/development/compilers/elm/registry.dat]
|
||||
|
@ -96,6 +98,9 @@ trim_trailing_whitespace = unset
|
|||
[pkgs/development/node-packages/composition.nix]
|
||||
insert_final_newline = unset
|
||||
|
||||
[pkgs/development/{perl-modules,ocaml-modules,tools/ocaml}/**]
|
||||
indent_style = unset
|
||||
|
||||
[pkgs/servers/dict/wordnet_structures.py]
|
||||
trim_trailing_whitespace = unset
|
||||
|
||||
|
|
|
@ -176,6 +176,10 @@
|
|||
/pkgs/applications/editors/emacs @adisbladis
|
||||
/pkgs/top-level/emacs-packages.nix @adisbladis
|
||||
|
||||
# Neovim
|
||||
/pkgs/applications/editors/neovim @jonringer
|
||||
/pkgs/applications/editors/neovim @teto
|
||||
|
||||
# VimPlugins
|
||||
/pkgs/misc/vim-plugins @jonringer @softinio
|
||||
|
||||
|
@ -202,8 +206,14 @@
|
|||
/nixos/tests/cri-o.nix @NixOS/podman @zowoq
|
||||
/nixos/tests/podman.nix @NixOS/podman @zowoq
|
||||
|
||||
# Docker tools
|
||||
/pkgs/build-support/docker @roberth @utdemir
|
||||
/nixos/tests/docker-tools-overlay.nix @roberth
|
||||
/nixos/tests/docker-tools.nix @roberth
|
||||
/doc/builders/images/dockertools.xml @roberth
|
||||
|
||||
# Blockchains
|
||||
/pkgs/applications/blockchains @mmahut
|
||||
/pkgs/applications/blockchains @mmahut @RaghavSood
|
||||
|
||||
# Go
|
||||
/pkgs/development/compilers/go @kalbasit @Mic92 @zowoq
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
---
|
||||
name: Out-of-date package reports
|
||||
about: For packages that are out-of-date
|
||||
title: ''
|
||||
labels: '9.needs: package (update)'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
###### Checklist
|
||||
|
||||
<!-- Note that these are hard requirements -->
|
||||
|
||||
<!--
|
||||
You can use the "Go to file" functionality on github to find the package
|
||||
Then you can go to the history for this package
|
||||
Find the latest "package_name: old_version -> new_version" commit
|
||||
The "new_version" is the the current version of the package
|
||||
-->
|
||||
- [ ] Checked the [nixpkgs master branch](https://github.com/NixOS/nixpkgs)
|
||||
<!--
|
||||
Type the name of your package and try to find an open pull request for the package
|
||||
If you find an open pull request, you can review it!
|
||||
There's a high chance that you'll have the new version right away while helping the community!
|
||||
-->
|
||||
- [ ] Checked the [nixpkgs pull requests](https://github.com/NixOS/nixpkgs/pulls)
|
||||
|
||||
###### Project name
|
||||
`nix search` name:
|
||||
<!--
|
||||
The current version can be found easily with the same process than above for checking the master branch
|
||||
If an open PR is present for the package, take this version as the current one and link to the PR
|
||||
-->
|
||||
current version:
|
||||
desired version:
|
||||
|
||||
###### Notify maintainers
|
||||
<!--
|
||||
Search your package here: https://search.nixos.org/packages?channel=unstable
|
||||
If no maintainer is listed for your package, tag the person that last updated the package
|
||||
-->
|
||||
|
||||
maintainers:
|
||||
|
||||
###### Note for maintainers
|
||||
|
||||
Please tag this issue in your PR.
|
|
@ -5,7 +5,7 @@ comment describing what you have tested in the relevant package/service.
|
|||
Reviewing helps to reduce the average time-to-merge for everyone.
|
||||
Thanks a lot if you do!
|
||||
List of open PRs: https://github.com/NixOS/nixpkgs/pulls
|
||||
Reviewing guidelines: https://hydra.nixos.org/job/nixpkgs/trunk/manual/latest/download/1/nixpkgs/manual.html#chap-reviewing-contributions
|
||||
Reviewing guidelines: https://nixos.org/manual/nixpkgs/unstable/#chap-reviewing-contributions
|
||||
-->
|
||||
|
||||
###### Motivation for this change
|
||||
|
|
|
@ -2,6 +2,8 @@ name: "Checking EditorConfig"
|
|||
|
||||
on:
|
||||
pull_request:
|
||||
branches-ignore:
|
||||
- 'release-**'
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
|
@ -23,5 +25,5 @@ jobs:
|
|||
- name: Checking EditorConfig
|
||||
if: env.GIT_DIFF
|
||||
run: |
|
||||
./bin/editorconfig-checker -disable-indentation \
|
||||
./bin/editorconfig-checker -disable-indent-size \
|
||||
${{ env.GIT_DIFF }}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
</p>
|
||||
|
||||
[Nixpkgs](https://github.com/nixos/nixpkgs) is a collection of over
|
||||
40,000 software packages that can be installed with the
|
||||
60,000 software packages that can be installed with the
|
||||
[Nix](https://nixos.org/nix/) package manager. It also implements
|
||||
[NixOS](https://nixos.org/nixos/), a purely-functional Linux distribution.
|
||||
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
<para>
|
||||
Kakoune can be built to autoload plugins:
|
||||
<programlisting>(kakoune.override {
|
||||
configure = {
|
||||
plugins = with pkgs.kakounePlugins; [ parinfer-rust ];
|
||||
};
|
||||
plugins = with pkgs.kakounePlugins; [ parinfer-rust ];
|
||||
})</programlisting>
|
||||
</para>
|
||||
</section>
|
||||
|
|
|
@ -6,20 +6,16 @@
|
|||
<para>
|
||||
Some packages provide the shell integration to be more useful. But unlike other systems, nix doesn't have a standard share directory location. This is why a bunch <command>PACKAGE-share</command> scripts are shipped that print the location of the corresponding shared folder. Current list of such packages is as following:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>autojump</literal>: <command>autojump-share</command>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>fzf</literal>: <command>fzf-share</command>
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
E.g. <literal>autojump</literal> can then used in the .bashrc like this:
|
||||
E.g. <literal>fzf</literal> can then used in the .bashrc like this:
|
||||
<screen>
|
||||
source "$(autojump-share)/autojump.bash"
|
||||
source "$(fzf-share)/completion.bash"
|
||||
source "$(fzf-share)/key-bindings.bash"
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
<warning>
|
||||
<para>
|
||||
The following section is a draft, and the policy for reviewing is still being discussed in issues such as <link
|
||||
xlink:href="https://github.com/NixOS/nixpkgs/issues/11166">#11166 </link> and <link
|
||||
xlink:href="https://github.com/NixOS/nixpkgs/issues/20836">#20836 </link>.
|
||||
xlink:href="https://github.com/NixOS/nixpkgs/issues/11166">#11166 </link> and <link
|
||||
xlink:href="https://github.com/NixOS/nixpkgs/issues/20836">#20836 </link>.
|
||||
</para>
|
||||
</warning>
|
||||
<para>
|
||||
|
@ -47,18 +47,6 @@
|
|||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
Add labels to the pull request. (Requires commit rights)
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>8.has: package (update)</literal> and any topic label that fit the updated package.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Ensure that the package versioning fits the guidelines.
|
||||
|
@ -186,18 +174,6 @@
|
|||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
Add labels to the pull request. (Requires commit rights)
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>8.has: package (new)</literal> and any topic label that fit the new package.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Ensure that the package versioning is fitting the guidelines.
|
||||
|
@ -302,18 +278,6 @@
|
|||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
Add labels to the pull request. (Requires commit rights)
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>8.has: module (update)</literal> and any topic label that fit the module.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Ensure that the module maintainers are notified.
|
||||
|
@ -406,18 +370,6 @@
|
|||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
Add labels to the pull request. (Requires commit rights)
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>8.has: module (new)</literal> and any topic label that fit the module.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Ensure that the module tests, if any, are succeeding.
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
# BEAM Languages (Erlang, Elixir & LFE) {#sec-beam}
|
||||
|
||||
## Introduction {#beam-introduction}
|
||||
|
||||
In this document and related Nix expressions, we use the term, *BEAM*, to describe the environment. BEAM is the name of the Erlang Virtual Machine and, as far as we're concerned, from a packaging perspective, all languages that run on the BEAM are interchangeable. That which varies, like the build system, is transparent to users of any given BEAM package, so we make no distinction.
|
||||
|
||||
## Structure {#beam-structure}
|
||||
|
||||
All BEAM-related expressions are available via the top-level `beam` attribute, which includes:
|
||||
|
||||
- `interpreters`: a set of compilers running on the BEAM, including multiple Erlang/OTP versions (`beam.interpreters.erlangR19`, etc), Elixir (`beam.interpreters.elixir`) and LFE (`beam.interpreters.lfe`).
|
||||
|
||||
- `packages`: a set of package builders (Mix and rebar3), each compiled with a specific Erlang/OTP version, e.g. `beam.packages.erlangR19`.
|
||||
|
||||
The default Erlang compiler, defined by `beam.interpreters.erlang`, is aliased as `erlang`. The default BEAM package set is defined by `beam.packages.erlang` and aliased at the top level as `beamPackages`.
|
||||
|
||||
To create a package builder built with a custom Erlang version, use the lambda, `beam.packagesWith`, which accepts an Erlang/OTP derivation and produces a package builder similar to `beam.packages.erlang`.
|
||||
|
||||
Many Erlang/OTP distributions available in `beam.interpreters` have versions with ODBC and/or Java enabled or without wx (no observer support). For example, there's `beam.interpreters.erlangR22_odbc_javac`, which corresponds to `beam.interpreters.erlangR22` and `beam.interpreters.erlangR22_nox`, which corresponds to `beam.interpreters.erlangR22`.
|
||||
|
||||
## Build Tools {#build-tools}
|
||||
|
||||
### Rebar3 {#build-tools-rebar3}
|
||||
|
||||
We provide a version of Rebar3, under `rebar3`. We also provide a helper to fetch Rebar3 dependencies from a lockfile under `fetchRebar3Deps`.
|
||||
|
||||
### Mix & Erlang.mk {#build-tools-other}
|
||||
|
||||
Both Mix and Erlang.mk work exactly as expected. There is a bootstrap process that needs to be run for both, however, which is supported by the `buildMix` and `buildErlangMk` derivations, respectively.
|
||||
|
||||
## How to Install BEAM Packages {#how-to-install-beam-packages}
|
||||
|
||||
BEAM builders are not registered at the top level, simply because they are not relevant to the vast majority of Nix users. To install any of those builders into your profile, refer to them by their attribute path `beamPackages.rebar3`:
|
||||
|
||||
```ShellSession
|
||||
$ nix-env -f "<nixpkgs>" -iA beamPackages.rebar3
|
||||
```
|
||||
|
||||
## Packaging BEAM Applications {#packaging-beam-applications}
|
||||
|
||||
### Erlang Applications {#packaging-erlang-applications}
|
||||
|
||||
#### Rebar3 Packages {#rebar3-packages}
|
||||
|
||||
The Nix function, `buildRebar3`, defined in `beam.packages.erlang.buildRebar3` and aliased at the top level, can be used to build a derivation that understands how to build a Rebar3 project.
|
||||
|
||||
If a package needs to compile native code via Rebar3's port compilation mechanism, add `compilePort = true;` to the derivation.
|
||||
|
||||
#### Erlang.mk Packages {#erlang-mk-packages}
|
||||
|
||||
Erlang.mk functions similarly to Rebar3, except we use `buildErlangMk` instead of `buildRebar3`.
|
||||
|
||||
#### Mix Packages {#mix-packages}
|
||||
|
||||
Mix functions similarly to Rebar3, except we use `buildMix` instead of `buildRebar3`.
|
||||
|
||||
Alternatively, we can use `buildHex` as a shortcut:
|
||||
|
||||
## How to Develop {#how-to-develop}
|
||||
|
||||
### Creating a Shell {#creating-a-shell}
|
||||
|
||||
Usually, we need to create a `shell.nix` file and do our development inside of the environment specified therein. Just install your version of erlang and other interpreter, and then user your normal build tools. As an example with elixir:
|
||||
|
||||
```nix
|
||||
{ pkgs ? import "<nixpkgs"> {} }:
|
||||
|
||||
with pkgs;
|
||||
|
||||
let
|
||||
|
||||
elixir = beam.packages.erlangR22.elixir_1_9;
|
||||
|
||||
in
|
||||
mkShell {
|
||||
buildInputs = [ elixir ];
|
||||
|
||||
ERL_INCLUDE_PATH="${erlang}/lib/erlang/usr/include";
|
||||
}
|
||||
```
|
||||
|
||||
#### Building in a Shell (for Mix Projects) {#building-in-a-shell}
|
||||
|
||||
Using a `shell.nix` as described (see <xref linkend="creating-a-shell"/>) should just work.
|
|
@ -1,159 +0,0 @@
|
|||
<section xmlns="http://docbook.org/ns/docbook"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xml:id="sec-beam">
|
||||
<title>BEAM Languages (Erlang, Elixir & LFE)</title>
|
||||
|
||||
<section xml:id="beam-introduction">
|
||||
<title>Introduction</title>
|
||||
|
||||
<para>
|
||||
In this document and related Nix expressions, we use the term, <emphasis>BEAM</emphasis>, to describe the environment. BEAM is the name of the Erlang Virtual Machine and, as far as we're concerned, from a packaging perspective, all languages that run on the BEAM are interchangeable. That which varies, like the build system, is transparent to users of any given BEAM package, so we make no distinction.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="beam-structure">
|
||||
<title>Structure</title>
|
||||
|
||||
<para>
|
||||
All BEAM-related expressions are available via the top-level <literal>beam</literal> attribute, which includes:
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>interpreters</literal>: a set of compilers running on the BEAM, including multiple Erlang/OTP versions (<literal>beam.interpreters.erlangR19</literal>, etc), Elixir (<literal>beam.interpreters.elixir</literal>) and LFE (<literal>beam.interpreters.lfe</literal>).
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>packages</literal>: a set of package builders (Mix and rebar3), each compiled with a specific Erlang/OTP version, e.g. <literal>beam.packages.erlangR19</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
The default Erlang compiler, defined by <literal>beam.interpreters.erlang</literal>, is aliased as <literal>erlang</literal>. The default BEAM package set is defined by <literal>beam.packages.erlang</literal> and aliased at the top level as <literal>beamPackages</literal>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To create a package builder built with a custom Erlang version, use the lambda, <literal>beam.packagesWith</literal>, which accepts an Erlang/OTP derivation and produces a package builder similar to <literal>beam.packages.erlang</literal>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Many Erlang/OTP distributions available in <literal>beam.interpreters</literal> have versions with ODBC and/or Java enabled or without wx (no observer support). For example, there's <literal>beam.interpreters.erlangR22_odbc_javac</literal>, which corresponds to <literal>beam.interpreters.erlangR22</literal> and <literal>beam.interpreters.erlangR22_nox</literal>, which corresponds to <literal>beam.interpreters.erlangR22</literal>.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="build-tools">
|
||||
<title>Build Tools</title>
|
||||
|
||||
<section xml:id="build-tools-rebar3">
|
||||
<title>Rebar3</title>
|
||||
|
||||
<para>
|
||||
We provide a version of Rebar3, under <literal>rebar3</literal>. We also provide a helper to fetch Rebar3 dependencies from a lockfile under <literal>fetchRebar3Deps</literal>.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="build-tools-other">
|
||||
<title>Mix & Erlang.mk</title>
|
||||
|
||||
<para>
|
||||
Both Mix and Erlang.mk work exactly as expected. There is a bootstrap process that needs to be run for both, however, which is supported by the <literal>buildMix</literal> and <literal>buildErlangMk</literal> derivations, respectively.
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section xml:id="how-to-install-beam-packages">
|
||||
<title>How to Install BEAM Packages</title>
|
||||
|
||||
<para>
|
||||
BEAM builders are not registered at the top level, simply because they are not relevant to the vast majority of Nix users.
|
||||
To install any of those builders into your profile, refer to them by their attribute path <literal>beamPackages.rebar3</literal>:
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
<prompt>$ </prompt>nix-env -f "<nixpkgs>" -iA beamPackages.rebar3
|
||||
</screen>
|
||||
</section>
|
||||
|
||||
<section xml:id="packaging-beam-applications">
|
||||
<title>Packaging BEAM Applications</title>
|
||||
|
||||
<section xml:id="packaging-erlang-applications">
|
||||
<title>Erlang Applications</title>
|
||||
|
||||
<section xml:id="rebar3-packages">
|
||||
<title>Rebar3 Packages</title>
|
||||
|
||||
<para>
|
||||
The Nix function, <literal>buildRebar3</literal>, defined in <literal>beam.packages.erlang.buildRebar3</literal> and aliased at the top level, can be used to build a derivation that understands how to build a Rebar3 project.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If a package needs to compile native code via Rebar3's port compilation mechanism, add <literal>compilePort = true;</literal> to the derivation.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="erlang-mk-packages">
|
||||
<title>Erlang.mk Packages</title>
|
||||
|
||||
<para>
|
||||
Erlang.mk functions similarly to Rebar3, except we use <literal>buildErlangMk</literal> instead of <literal>buildRebar3</literal>.
|
||||
</para>
|
||||
|
||||
</section>
|
||||
|
||||
<section xml:id="mix-packages">
|
||||
<title>Mix Packages</title>
|
||||
|
||||
<para>
|
||||
Mix functions similarly to Rebar3, except we use <literal>buildMix</literal> instead of <literal>buildRebar3</literal>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Alternatively, we can use <literal>buildHex</literal> as a shortcut:
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section xml:id="how-to-develop">
|
||||
<title>How to Develop</title>
|
||||
|
||||
<section xml:id="creating-a-shell">
|
||||
<title>Creating a Shell</title>
|
||||
|
||||
<para>
|
||||
Usually, we need to create a <literal>shell.nix</literal> file and do our development inside of the environment specified therein. Just install your version of erlang and other interpreter, and then user your normal build tools.
|
||||
As an example with elixir:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
{ pkgs ? import "<nixpkgs"> {} }:
|
||||
|
||||
with pkgs;
|
||||
|
||||
let
|
||||
|
||||
elixir = beam.packages.erlangR22.elixir_1_9;
|
||||
|
||||
in
|
||||
mkShell {
|
||||
buildInputs = [ elixir ];
|
||||
|
||||
ERL_INCLUDE_PATH="${erlang}/lib/erlang/usr/include";
|
||||
}
|
||||
</programlisting>
|
||||
|
||||
<section xml:id="building-in-a-shell">
|
||||
<title>Building in a Shell (for Mix Projects)</title>
|
||||
|
||||
<para>
|
||||
Using a <literal>shell.nix</literal> as described (see <xref
|
||||
linkend="creating-a-shell"/>) should just work.
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
|
@ -64,9 +64,9 @@ $ dotnet --info
|
|||
|
||||
The `dotnetCorePackages.sdk_X_Y` is preferred over the old dotnet-sdk as both major and minor version are very important for a dotnet environment. If a given minor version isn't present (or was changed), then this will likely break your ability to build a project.
|
||||
|
||||
## dotnetCorePackages.sdk vs dotnetCorePackages.netcore vs dotnetCorePackages.aspnetcore
|
||||
## dotnetCorePackages.sdk vs vs dotnetCorePackages.net vs dotnetCorePackages.netcore vs dotnetCorePackages.aspnetcore
|
||||
|
||||
The `dotnetCorePackages.sdk` contains both a runtime and the full sdk of a given version. The `netcore` and `aspnetcore` packages are meant to serve as minimal runtimes to deploy alongside already built applications.
|
||||
The `dotnetCorePackages.sdk` contains both a runtime and the full sdk of a given version. The `net`, `netcore` and `aspnetcore` packages are meant to serve as minimal runtimes to deploy alongside already built applications. For runtime versions >= .NET 5 `net` is used while `netcore` is used for older .NET Core runtime version.
|
||||
|
||||
## Packaging a Dotnet Application
|
||||
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
# Go {#sec-language-go}
|
||||
|
||||
## Go modules {#ssec-language-go}
|
||||
|
||||
The function `buildGoModule` builds Go programs managed with Go modules. It builds a [Go Modules](https://github.com/golang/go/wiki/Modules) through a two phase build:
|
||||
|
||||
- An intermediate fetcher derivation. This derivation will be used to fetch all of the dependencies of the Go module.
|
||||
- A final derivation will use the output of the intermediate derivation to build the binaries and produce the final output.
|
||||
|
||||
### Example for `buildGoModule` {#ex-buildGoModule}
|
||||
|
||||
In the following is an example expression using `buildGoModule`, the following arguments are of special significance to the function:
|
||||
|
||||
- `vendorSha256`: is the hash of the output of the intermediate fetcher derivation. `vendorSha256` can also take `null` as an input. When `null` is used as a value, rather than fetching the dependencies and vendoring them, we use the vendoring included within the source repo. If you'd like to not have to update this field on dependency changes, run `go mod vendor` in your source repo and set `vendorSha256 = null;`
|
||||
- `runVend`: runs the vend command to generate the vendor directory. This is useful if your code depends on c code and go mod tidy does not include the needed sources to build.
|
||||
|
||||
```nix
|
||||
pet = buildGoModule rec {
|
||||
pname = "pet";
|
||||
version = "0.3.4";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "knqyf263";
|
||||
repo = "pet";
|
||||
rev = "v${version}";
|
||||
sha256 = "0m2fzpqxk7hrbxsgqplkg7h2p7gv6s1miymv3gvw0cz039skag0s";
|
||||
};
|
||||
|
||||
vendorSha256 = "1879j77k96684wi554rkjxydrj8g3hpp0kvxz03sd8dmwr3lh83j";
|
||||
|
||||
runVend = true;
|
||||
|
||||
meta = with lib; {
|
||||
description = "Simple command-line snippet manager, written in Go";
|
||||
homepage = "https://github.com/knqyf263/pet";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ kalbasit ];
|
||||
platforms = platforms.linux ++ platforms.darwin;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## `buildGoPackage` (legacy) {#ssec-go-legacy}
|
||||
|
||||
The function `buildGoPackage` builds legacy Go programs, not supporting Go modules.
|
||||
|
||||
### Example for `buildGoPackage`
|
||||
|
||||
In the following is an example expression using buildGoPackage, the following arguments are of special significance to the function:
|
||||
|
||||
- `goPackagePath` specifies the package's canonical Go import path.
|
||||
- `goDeps` is where the Go dependencies of a Go program are listed as a list of package source identified by Go import path. It could be imported as a separate `deps.nix` file for readability. The dependency data structure is described below.
|
||||
|
||||
```nix
|
||||
deis = buildGoPackage rec {
|
||||
pname = "deis";
|
||||
version = "1.13.0";
|
||||
|
||||
goPackagePath = "github.com/deis/deis";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "deis";
|
||||
repo = "deis";
|
||||
rev = "v${version}";
|
||||
sha256 = "1qv9lxqx7m18029lj8cw3k7jngvxs4iciwrypdy0gd2nnghc68sw";
|
||||
};
|
||||
|
||||
goDeps = ./deps.nix;
|
||||
}
|
||||
```
|
||||
|
||||
The `goDeps` attribute can be imported from a separate `nix` file that defines which Go libraries are needed and should be included in `GOPATH` for `buildPhase`:
|
||||
|
||||
```nix
|
||||
# deps.nix
|
||||
[ # goDeps is a list of Go dependencies.
|
||||
{
|
||||
# goPackagePath specifies Go package import path.
|
||||
goPackagePath = "gopkg.in/yaml.v2";
|
||||
fetch = {
|
||||
# `fetch type` that needs to be used to get package source.
|
||||
# If `git` is used there should be `url`, `rev` and `sha256` defined next to it.
|
||||
type = "git";
|
||||
url = "https://gopkg.in/yaml.v2";
|
||||
rev = "a83829b6f1293c91addabc89d0571c246397bbf4";
|
||||
sha256 = "1m4dsmk90sbi17571h6pld44zxz7jc4lrnl4f27dpd1l8g5xvjhh";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/docopt/docopt-go";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/docopt/docopt-go";
|
||||
rev = "784ddc588536785e7299f7272f39101f7faccc3f";
|
||||
sha256 = "0wwz48jl9fvl1iknvn9dqr4gfy1qs03gxaikrxxp9gry6773v3sj";
|
||||
};
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
To extract dependency information from a Go package in automated way use [go2nix](https://github.com/kamilchm/go2nix). It can produce complete derivation and `goDeps` file for Go programs.
|
||||
|
||||
You may use Go packages installed into the active Nix profiles by adding the following to your ~/.bashrc:
|
||||
|
||||
```bash
|
||||
for p in $NIX_PROFILES; do
|
||||
GOPATH="$p/share/go:$GOPATH"
|
||||
done
|
||||
```
|
||||
|
||||
## Attributes used by the builders {#ssec-go-common-attributes}
|
||||
|
||||
Both `buildGoModule` and `buildGoPackage` can be tweaked to behave slightly differently, if the following attributes are used:
|
||||
|
||||
### `buildFlagsArray` and `buildFlags`: {#ex-goBuildFlags-noarray}
|
||||
|
||||
These attributes set build flags supported by `go build`. We recommend using `buildFlagsArray`. The most common use case of these attributes is to make the resulting executable aware of its own version. For example:
|
||||
|
||||
```nix
|
||||
buildFlagsArray = [
|
||||
# Note: single quotes are not needed.
|
||||
"-ldflags=-X main.Version=${version} -X main.Commit=${version}"
|
||||
];
|
||||
```
|
||||
|
||||
```nix
|
||||
buildFlagsArray = ''
|
||||
-ldflags=
|
||||
-X main.Version=${version}
|
||||
-X main.Commit=${version}
|
||||
'';
|
||||
```
|
||||
|
||||
### `deleteVendor` {#var-go-deleteVendor}
|
||||
|
||||
Removes the pre-existing vendor directory. This should only be used if the dependencies included in the vendor folder are broken or incomplete.
|
||||
|
||||
### `subPackages` {#var-go-subPackages}
|
||||
|
||||
Limits the builder from building child packages that have not been listed. If <varname>subPackages</varname> is not specified, all child packages will be built.
|
|
@ -1,248 +0,0 @@
|
|||
<section xmlns="http://docbook.org/ns/docbook"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xml:id="sec-language-go">
|
||||
<title>Go</title>
|
||||
|
||||
<section xml:id="ssec-go-modules">
|
||||
<title>Go modules</title>
|
||||
|
||||
<para>
|
||||
The function <varname> buildGoModule </varname> builds Go programs managed with Go modules. It builds a <link xlink:href="https://github.com/golang/go/wiki/Modules">Go modules</link> through a two phase build:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
An intermediate fetcher derivation. This derivation will be used to fetch all of the dependencies of the Go module.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
A final derivation will use the output of the intermediate derivation to build the binaries and produce the final output.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
|
||||
<example xml:id='ex-buildGoModule'>
|
||||
<title>buildGoModule</title>
|
||||
<programlisting>
|
||||
pet = buildGoModule rec {
|
||||
pname = "pet";
|
||||
version = "0.3.4";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "knqyf263";
|
||||
repo = "pet";
|
||||
rev = "v${version}";
|
||||
sha256 = "0m2fzpqxk7hrbxsgqplkg7h2p7gv6s1miymv3gvw0cz039skag0s";
|
||||
};
|
||||
|
||||
vendorSha256 = "1879j77k96684wi554rkjxydrj8g3hpp0kvxz03sd8dmwr3lh83j"; <co xml:id='ex-buildGoModule-1' />
|
||||
|
||||
runVend = true; <co xml:id='ex-buildGoModule-2' />
|
||||
|
||||
meta = with lib; {
|
||||
description = "Simple command-line snippet manager, written in Go";
|
||||
homepage = "https://github.com/knqyf263/pet";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ kalbasit ];
|
||||
platforms = platforms.linux ++ platforms.darwin;
|
||||
};
|
||||
}
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
<xref linkend='ex-buildGoModule'/> is an example expression using buildGoModule, the following arguments are of special significance to the function:
|
||||
<calloutlist>
|
||||
<callout arearefs='ex-buildGoModule-1'>
|
||||
<para>
|
||||
<varname>vendorSha256</varname> is the hash of the output of the intermediate fetcher derivation.
|
||||
</para>
|
||||
</callout>
|
||||
<callout arearefs='ex-buildGoModule-2'>
|
||||
<para>
|
||||
<varname>runVend</varname> runs the vend command to generate the vendor directory. This is useful if your code depends on c code and go mod tidy does not include the needed sources to build.
|
||||
</para>
|
||||
</callout>
|
||||
</calloutlist>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<varname>vendorSha256</varname> can also take <varname>null</varname> as an input. When `null` is used as a value, rather than fetching the dependencies and vendoring them, we use the vendoring included within the source repo. If you'd like to not have to update this field on dependency changes, run `go mod vendor` in your source repo and set 'vendorSha256 = null;'
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="ssec-go-legacy">
|
||||
<title>Go legacy</title>
|
||||
|
||||
<para>
|
||||
The function <varname> buildGoPackage </varname> builds legacy Go programs, not supporting Go modules.
|
||||
</para>
|
||||
|
||||
<example xml:id='ex-buildGoPackage'>
|
||||
<title>buildGoPackage</title>
|
||||
<programlisting>
|
||||
deis = buildGoPackage rec {
|
||||
pname = "deis";
|
||||
version = "1.13.0";
|
||||
|
||||
goPackagePath = "github.com/deis/deis"; <co xml:id='ex-buildGoPackage-1' />
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "deis";
|
||||
repo = "deis";
|
||||
rev = "v${version}";
|
||||
sha256 = "1qv9lxqx7m18029lj8cw3k7jngvxs4iciwrypdy0gd2nnghc68sw";
|
||||
};
|
||||
|
||||
goDeps = ./deps.nix; <co xml:id='ex-buildGoPackage-2' />
|
||||
}
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
<xref linkend='ex-buildGoPackage'/> is an example expression using buildGoPackage, the following arguments are of special significance to the function:
|
||||
<calloutlist>
|
||||
<callout arearefs='ex-buildGoPackage-1'>
|
||||
<para>
|
||||
<varname>goPackagePath</varname> specifies the package's canonical Go import path.
|
||||
</para>
|
||||
</callout>
|
||||
<callout arearefs='ex-buildGoPackage-2'>
|
||||
<para>
|
||||
<varname>goDeps</varname> is where the Go dependencies of a Go program are listed as a list of package source identified by Go import path. It could be imported as a separate <varname>deps.nix</varname> file for readability. The dependency data structure is described below.
|
||||
</para>
|
||||
</callout>
|
||||
</calloutlist>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The <varname>goDeps</varname> attribute can be imported from a separate <varname>nix</varname> file that defines which Go libraries are needed and should be included in <varname>GOPATH</varname> for <varname>buildPhase</varname>.
|
||||
</para>
|
||||
|
||||
<example xml:id='ex-goDeps'>
|
||||
<title>deps.nix</title>
|
||||
<programlisting>
|
||||
[ <co xml:id='ex-goDeps-1' />
|
||||
{
|
||||
goPackagePath = "gopkg.in/yaml.v2"; <co xml:id='ex-goDeps-2' />
|
||||
fetch = {
|
||||
type = "git"; <co xml:id='ex-goDeps-3' />
|
||||
url = "https://gopkg.in/yaml.v2";
|
||||
rev = "a83829b6f1293c91addabc89d0571c246397bbf4";
|
||||
sha256 = "1m4dsmk90sbi17571h6pld44zxz7jc4lrnl4f27dpd1l8g5xvjhh";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/docopt/docopt-go";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/docopt/docopt-go";
|
||||
rev = "784ddc588536785e7299f7272f39101f7faccc3f";
|
||||
sha256 = "0wwz48jl9fvl1iknvn9dqr4gfy1qs03gxaikrxxp9gry6773v3sj";
|
||||
};
|
||||
}
|
||||
]
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
<calloutlist>
|
||||
<callout arearefs='ex-goDeps-1'>
|
||||
<para>
|
||||
<varname>goDeps</varname> is a list of Go dependencies.
|
||||
</para>
|
||||
</callout>
|
||||
<callout arearefs='ex-goDeps-2'>
|
||||
<para>
|
||||
<varname>goPackagePath</varname> specifies Go package import path.
|
||||
</para>
|
||||
</callout>
|
||||
<callout arearefs='ex-goDeps-3'>
|
||||
<para>
|
||||
<varname>fetch type</varname> that needs to be used to get package source. If <varname>git</varname> is used there should be <varname>url</varname>, <varname>rev</varname> and <varname>sha256</varname> defined next to it.
|
||||
</para>
|
||||
</callout>
|
||||
</calloutlist>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To extract dependency information from a Go package in automated way use <link xlink:href="https://github.com/kamilchm/go2nix">go2nix</link>. It can produce complete derivation and <varname>goDeps</varname> file for Go programs.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
You may use Go packages installed into the active Nix profiles by adding the following to your ~/.bashrc:
|
||||
<screen>
|
||||
for p in $NIX_PROFILES; do
|
||||
GOPATH="$p/share/go:$GOPATH"
|
||||
done
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="ssec-go-common-attributes">
|
||||
<title>Attributes used by the builders</title>
|
||||
|
||||
<para>
|
||||
Both <link xlink:href="#ssec-go-modules"><varname>buildGoModule</varname></link> and <link xlink:href="#ssec-go-modules"><varname>buildGoPackage</varname></link> can be tweaked to behave slightly differently, if the following attributes are used:
|
||||
</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry xml:id="var-go-buildFlagsArray">
|
||||
<term>
|
||||
<varname>buildFlagsArray</varname> and <varname>buildFlags</varname>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
These attributes set build flags supported by <varname>go build</varname>. We recommend using <varname>buildFlagsArray</varname>. The most common use case of these attributes is to make the resulting executable aware of its own version. For example:
|
||||
</para>
|
||||
<example xml:id='ex-goBuildFlags-nospaces'>
|
||||
<title>buildFlagsArray</title>
|
||||
<programlisting>
|
||||
buildFlagsArray = [
|
||||
"-ldflags=-X main.Version=${version} -X main.Commit=${version}" <co xml:id='ex-goBuildFlags-1' />
|
||||
];
|
||||
</programlisting>
|
||||
</example>
|
||||
<calloutlist>
|
||||
<callout arearefs='ex-goBuildFlags-1'>
|
||||
<para>
|
||||
Note: single quotes are not needed.
|
||||
</para>
|
||||
</callout>
|
||||
</calloutlist>
|
||||
<example xml:id='ex-goBuildFlags-noarray'>
|
||||
<title>buildFlagsArray</title>
|
||||
<programlisting>
|
||||
buildFlagsArray = ''
|
||||
-ldflags=
|
||||
-X main.Version=${version}
|
||||
-X main.Commit=${version}
|
||||
'';
|
||||
</programlisting>
|
||||
</example>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry xml:id="var-go-deleteVendor">
|
||||
<term>
|
||||
<varname>deleteVendor</varname>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Removes the pre-existing vendor directory. This should only be used if the dependencies included in the vendor folder are broken or incomplete.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry xml:id="var-go-subPackages">
|
||||
<term>
|
||||
<varname>subPackages</varname>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Limits the builder from building child packages that have not been listed. If <varname>subPackages</varname> is not specified, all child packages will be built.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</section>
|
||||
</section>
|
|
@ -7,18 +7,19 @@
|
|||
</para>
|
||||
<xi:include href="agda.section.xml" />
|
||||
<xi:include href="android.section.xml" />
|
||||
<xi:include href="beam.xml" />
|
||||
<xi:include href="beam.section.xml" />
|
||||
<xi:include href="bower.xml" />
|
||||
<xi:include href="coq.xml" />
|
||||
<xi:include href="crystal.section.xml" />
|
||||
<xi:include href="emscripten.section.xml" />
|
||||
<xi:include href="gnome.xml" />
|
||||
<xi:include href="go.xml" />
|
||||
<xi:include href="go.section.xml" />
|
||||
<xi:include href="haskell.section.xml" />
|
||||
<xi:include href="idris.section.xml" />
|
||||
<xi:include href="ios.section.xml" />
|
||||
<xi:include href="java.xml" />
|
||||
<xi:include href="lua.section.xml" />
|
||||
<xi:include href="maven.section.xml" />
|
||||
<xi:include href="node.section.xml" />
|
||||
<xi:include href="ocaml.xml" />
|
||||
<xi:include href="perl.xml" />
|
||||
|
@ -26,7 +27,7 @@
|
|||
<xi:include href="python.section.xml" />
|
||||
<xi:include href="qt.xml" />
|
||||
<xi:include href="r.section.xml" />
|
||||
<xi:include href="ruby.xml" />
|
||||
<xi:include href="ruby.section.xml" />
|
||||
<xi:include href="rust.section.xml" />
|
||||
<xi:include href="texlive.xml" />
|
||||
<xi:include href="titanium.section.xml" />
|
||||
|
|
|
@ -32,7 +32,7 @@ nativeBuildInputs = [ jdk ];
|
|||
</para>
|
||||
|
||||
<para>
|
||||
If your Java package provides a program, you need to generate a wrapper script to run it using the OpenJRE. You can use <literal>makeWrapper</literal> for this:
|
||||
If your Java package provides a program, you need to generate a wrapper script to run it using a JRE. You can use <literal>makeWrapper</literal> for this:
|
||||
<programlisting>
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
|
@ -43,7 +43,21 @@ installPhase =
|
|||
--add-flags "-cp $out/share/java/foo.jar org.foo.Main"
|
||||
'';
|
||||
</programlisting>
|
||||
Note the use of <literal>jre</literal>, which is the part of the OpenJDK package that contains the Java Runtime Environment. By using <literal>${jre}/bin/java</literal> instead of <literal>${jdk}/bin/java</literal>, you prevent your package from depending on the JDK at runtime.
|
||||
Since the introduction of the Java Platform Module System in Java 9, Java distributions typically no longer ship with a general-purpose JRE: instead, they allow generating a JRE with only the modules required for your application(s). Because we can't predict what modules will be needed on a general-purpose system, the default <package>jre</package> package is the full JDK. When building a minimal system/image, you can override the <literal>modules</literal> parameter on <literal>jre_minimal</literal> to build a JRE with only the modules relevant for you:
|
||||
<programlisting>
|
||||
let
|
||||
my_jre = pkgs.jre_minimal.override {
|
||||
modules = [
|
||||
# The modules used by 'something' and 'other' combined:
|
||||
"java.base"
|
||||
"java.logging"
|
||||
];
|
||||
};
|
||||
something = (pkgs.something.override { jre = my_jre; });
|
||||
other = (pkgs.other.override { jre = my_jre; });
|
||||
in
|
||||
...
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
|
|
|
@ -0,0 +1,354 @@
|
|||
---
|
||||
title: Maven
|
||||
author: Farid Zakaria
|
||||
date: 2020-10-15
|
||||
---
|
||||
|
||||
# Maven
|
||||
|
||||
Maven is a well-known build tool for the Java ecosystem however it has some challenges when integrating into the Nix build system.
|
||||
|
||||
The following provides a list of common patterns with how to package a Maven project (or any JVM language that can export to Maven) as a Nix package.
|
||||
|
||||
For the purposes of this example let's consider a very basic Maven project with the following `pom.xml` with a single dependency on [emoji-java](https://github.com/vdurmont/emoji-java).
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>io.github.fzakaria</groupId>
|
||||
<artifactId>maven-demo</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>NixOS Maven Demo</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.vdurmont</groupId>
|
||||
<artifactId>emoji-java</artifactId>
|
||||
<version>5.1.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
```
|
||||
|
||||
Our main class file will be very simple:
|
||||
|
||||
```java
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
String str = "NixOS :grinning: is super cool :smiley:!";
|
||||
String result = EmojiParser.parseToUnicode(str);
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You find this demo project at https://github.com/fzakaria/nixos-maven-example
|
||||
|
||||
## Solving for dependencies
|
||||
|
||||
### buildMaven with NixOS/mvn2nix-maven-plugin
|
||||
|
||||
> ⚠️ Although `buildMaven` is the "blessed" way within nixpkgs, as of 2020, it hasn't seen much activity in quite a while.
|
||||
|
||||
`buildMaven` is an alternative method that tries to follow similar patterns of other programming languages by generating a lock file. It relies on the maven plugin [mvn2nix-maven-plugin](https://github.com/NixOS/mvn2nix-maven-plugin).
|
||||
|
||||
First you generate a `project-info.json` file using the maven plugin.
|
||||
|
||||
> This should be executed in the project's source repository or be told which `pom.xml` to execute with.
|
||||
|
||||
```bash
|
||||
# run this step within the project's source repository
|
||||
❯ mvn org.nixos.mvn2nix:mvn2nix-maven-plugin:mvn2nix
|
||||
|
||||
❯ cat project-info.json | jq | head
|
||||
{
|
||||
"project": {
|
||||
"artifactId": "maven-demo",
|
||||
"groupId": "org.nixos",
|
||||
"version": "1.0",
|
||||
"classifier": "",
|
||||
"extension": "jar",
|
||||
"dependencies": [
|
||||
{
|
||||
"artifactId": "maven-resources-plugin",
|
||||
```
|
||||
|
||||
This file is then given to the `buildMaven` function, and it returns 2 attributes.
|
||||
|
||||
**`repo`**:
|
||||
A Maven repository that is a symlink farm of all the dependencies found in the `project-info.json`
|
||||
|
||||
|
||||
**`build`**:
|
||||
A simple derivation that runs through `mvn compile` & `mvn package` to build the JAR. You may use this as inspiration for more complicated derivations.
|
||||
|
||||
Here is an [example](https://github.com/fzakaria/nixos-maven-example/blob/main/build-maven-repository.nix) of building the Maven repository
|
||||
```nix
|
||||
{ pkgs ? import <nixpkgs> { } }:
|
||||
with pkgs;
|
||||
(buildMaven ./project-info.json).repo
|
||||
```
|
||||
|
||||
The benefit over the _double invocation_ as we will see below, is that the _/nix/store_ entry is a _linkFarm_ of every package, so that changes to your dependency set doesn't involve downloading everything from scratch.
|
||||
|
||||
```bash
|
||||
❯ tree $(nix-build --no-out-link build-maven-repository.nix) | head
|
||||
/nix/store/g87va52nkc8jzbmi1aqdcf2f109r4dvn-maven-repository
|
||||
├── antlr
|
||||
│ └── antlr
|
||||
│ └── 2.7.2
|
||||
│ ├── antlr-2.7.2.jar -> /nix/store/d027c8f2cnmj5yrynpbq2s6wmc9cb559-antlr-2.7.2.jar
|
||||
│ └── antlr-2.7.2.pom -> /nix/store/mv42fc5gizl8h5g5vpywz1nfiynmzgp2-antlr-2.7.2.pom
|
||||
├── avalon-framework
|
||||
│ └── avalon-framework
|
||||
│ └── 4.1.3
|
||||
│ ├── avalon-framework-4.1.3.jar -> /nix/store/iv5fp3955w3nq28ff9xfz86wvxbiw6n9-avalon-framework-4.1.3.jar
|
||||
```
|
||||
### Double Invocation
|
||||
|
||||
> ⚠️ This pattern is the simplest but may cause unnecessary rebuilds due to the output hash changing.
|
||||
|
||||
The double invocation is a _simple_ way to get around the problem that `nix-build` may be sandboxed and have no Internet connectivity.
|
||||
|
||||
It treats the entire Maven repository as a single source to be downloaded, relying on Maven's dependency resolution to satisfy the output hash. This is similar to fetchers like `fetchgit`, except it has to run a Maven build to determine what to download.
|
||||
|
||||
The first step will be to build the Maven project as a fixed-output derivation in order to collect the Maven repository -- below is an [example](https://github.com/fzakaria/nixos-maven-example/blob/main/double-invocation-repository.nix).
|
||||
|
||||
> Traditionally the Maven repository is at `~/.m2/repository`. We will override this to be the `$out` directory.
|
||||
|
||||
```nix
|
||||
{ stdenv, maven }:
|
||||
stdenv.mkDerivation {
|
||||
name = "maven-repository";
|
||||
buildInputs = [ maven ];
|
||||
src = ./.; # or fetchFromGitHub, cleanSourceWith, etc
|
||||
buildPhase = ''
|
||||
mvn package -Dmaven.repo.local=$out
|
||||
'';
|
||||
|
||||
# keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
|
||||
installPhase = ''
|
||||
find $out -type f \
|
||||
-name \*.lastUpdated -or \
|
||||
-name resolver-status.properties -or \
|
||||
-name _remote.repositories \
|
||||
-delete
|
||||
'';
|
||||
|
||||
# don't do any fixup
|
||||
dontFixup = true;
|
||||
outputHashAlgo = "sha256";
|
||||
outputHashMode = "recursive";
|
||||
# replace this with the correct SHA256
|
||||
outputHash = stdenv.lib.fakeSha256;
|
||||
}
|
||||
```
|
||||
|
||||
The build will fail, and tell you the expected `outputHash` to place. When you've set the hash, the build will return with a `/nix/store` entry whose contents are the full Maven repository.
|
||||
|
||||
> Some additional files are deleted that would cause the output hash to change potentially on subsequent runs.
|
||||
|
||||
```bash
|
||||
❯ tree $(nix-build --no-out-link double-invocation-repository.nix) | head
|
||||
/nix/store/8kicxzp98j68xyi9gl6jda67hp3c54fq-maven-repository
|
||||
├── backport-util-concurrent
|
||||
│ └── backport-util-concurrent
|
||||
│ └── 3.1
|
||||
│ ├── backport-util-concurrent-3.1.pom
|
||||
│ └── backport-util-concurrent-3.1.pom.sha1
|
||||
├── classworlds
|
||||
│ └── classworlds
|
||||
│ ├── 1.1
|
||||
│ │ ├── classworlds-1.1.jar
|
||||
```
|
||||
|
||||
If your package uses _SNAPSHOT_ dependencies or _version ranges_; there is a strong likelihood that over-time your output hash will change since the resolved dependencies may change. Hence this method is less recommended then using `buildMaven`.
|
||||
|
||||
## Building a JAR
|
||||
|
||||
Regardless of which strategy is chosen above, the step to build the derivation is the same.
|
||||
|
||||
```nix
|
||||
{ stdenv, lib, maven, callPackage }:
|
||||
# pick a repository derivation, here we will use buildMaven
|
||||
let repository = callPackage ./build-maven-repository.nix { };
|
||||
in stdenv.mkDerivation rec {
|
||||
pname = "maven-demo";
|
||||
version = "1.0";
|
||||
|
||||
src = builtins.fetchTarball "https://github.com/fzakaria/nixos-maven-example/archive/main.tar.gz";
|
||||
buildInputs = [ maven ];
|
||||
|
||||
buildPhase = ''
|
||||
echo "Using repository ${repository}"
|
||||
mvn --offline -Dmaven.repo.local=${repository} package;
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
install -Dm644 target/${pname}-${version}.jar $out/share/java
|
||||
'';
|
||||
}
|
||||
```
|
||||
|
||||
> We place the library in `$out/share/java` since JDK package has a _stdenv setup hook_ that adds any JARs in the `share/java` directories of the build inputs to the CLASSPATH environment.
|
||||
|
||||
```bash
|
||||
❯ tree $(nix-build --no-out-link build-jar.nix)
|
||||
/nix/store/7jw3xdfagkc2vw8wrsdv68qpsnrxgvky-maven-demo-1.0
|
||||
└── share
|
||||
└── java
|
||||
└── maven-demo-1.0.jar
|
||||
|
||||
2 directories, 1 file
|
||||
```
|
||||
|
||||
## Runnable JAR
|
||||
|
||||
The previous example builds a `jar` file but that's not a file one can run.
|
||||
|
||||
You need to use it with `java -jar $out/share/java/output.jar` and make sure to provide the required dependencies on the classpath.
|
||||
|
||||
The following explains how to use `makeWrapper` in order to make the derivation produce an executable that will run the JAR file you created.
|
||||
|
||||
We will use the same repository we built above (either _double invocation_ or _buildMaven_) to setup a CLASSPATH for our JAR.
|
||||
|
||||
The following two methods are more suited to Nix then building an [UberJar](https://imagej.net/Uber-JAR) which may be the more traditional approach.
|
||||
|
||||
### CLASSPATH
|
||||
|
||||
> This is ideal if you are providing a derivation for _nixpkgs_ and don't want to patch the project's `pom.xml`.
|
||||
|
||||
We will read the Maven repository and flatten it to a single list. This list will then be concatenated with the _CLASSPATH_ separator to create the full classpath.
|
||||
|
||||
We make sure to provide this classpath to the `makeWrapper`.
|
||||
|
||||
```nix
|
||||
{ stdenv, lib, maven, callPackage, makeWrapper, jre }:
|
||||
let
|
||||
repository = callPackage ./build-maven-repository.nix { };
|
||||
in stdenv.mkDerivation rec {
|
||||
pname = "maven-demo";
|
||||
version = "1.0";
|
||||
|
||||
src = builtins.fetchTarball
|
||||
"https://github.com/fzakaria/nixos-maven-example/archive/main.tar.gz";
|
||||
buildInputs = [ maven makeWrapper ];
|
||||
|
||||
buildPhase = ''
|
||||
echo "Using repository ${repository}"
|
||||
mvn --offline -Dmaven.repo.local=${repository} package;
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
|
||||
classpath=$(find ${repository} -name "*.jar" -printf ':%h/%f');
|
||||
install -Dm644 target/${pname}-${version}.jar $out/share/java
|
||||
# create a wrapper that will automatically set the classpath
|
||||
# this should be the paths from the dependency derivation
|
||||
makeWrapper ${jre}/bin/java $out/bin/${pname} \
|
||||
--add-flags "-classpath $out/share/java/${pname}-${version}.jar:''${classpath#:}" \
|
||||
--add-flags "Main"
|
||||
'';
|
||||
}
|
||||
```
|
||||
|
||||
### MANIFEST file via Maven Plugin
|
||||
|
||||
> This is ideal if you are the project owner and want to change your `pom.xml` to set the CLASSPATH within it.
|
||||
|
||||
Augment the `pom.xml` to create a JAR with the following manifest:
|
||||
```xml
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<classpathPrefix>../../repository/</classpathPrefix>
|
||||
<classpathLayoutType>repository</classpathLayoutType>
|
||||
<mainClass>Main</mainClass>
|
||||
</manifest>
|
||||
<manifestEntries>
|
||||
<Class-Path>.</Class-Path>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
```
|
||||
|
||||
The above plugin instructs the JAR to look for the necessary dependencies in the `lib/` relative folder. The layout of the folder is also in the _maven repository_ style.
|
||||
|
||||
```bash
|
||||
❯ unzip -q -c $(nix-build --no-out-link runnable-jar.nix)/share/java/maven-demo-1.0.jar META-INF/MANIFEST.MF
|
||||
|
||||
Manifest-Version: 1.0
|
||||
Archiver-Version: Plexus Archiver
|
||||
Built-By: nixbld
|
||||
Class-Path: . ../../repository/com/vdurmont/emoji-java/5.1.1/emoji-jav
|
||||
a-5.1.1.jar ../../repository/org/json/json/20170516/json-20170516.jar
|
||||
Created-By: Apache Maven 3.6.3
|
||||
Build-Jdk: 1.8.0_265
|
||||
Main-Class: Main
|
||||
```
|
||||
|
||||
We will modify the derivation above to add a symlink to our repository so that it's accessible to our JAR during the `installPhase`.
|
||||
|
||||
```nix
|
||||
{ stdenv, lib, maven, callPackage, makeWrapper, jre }:
|
||||
# pick a repository derivation, here we will use buildMaven
|
||||
let repository = callPackage ./build-maven-repository.nix { };
|
||||
in stdenv.mkDerivation rec {
|
||||
pname = "maven-demo";
|
||||
version = "1.0";
|
||||
|
||||
src = builtins.fetchTarball
|
||||
"https://github.com/fzakaria/nixos-maven-example/archive/main.tar.gz";
|
||||
buildInputs = [ maven makeWrapper ];
|
||||
|
||||
buildPhase = ''
|
||||
echo "Using repository ${repository}"
|
||||
mvn --offline -Dmaven.repo.local=${repository} package;
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
|
||||
# create a symbolic link for the repository directory
|
||||
ln -s ${repository} $out/repository
|
||||
|
||||
install -Dm644 target/${pname}-${version}.jar $out/share/java
|
||||
# create a wrapper that will automatically set the classpath
|
||||
# this should be the paths from the dependency derivation
|
||||
makeWrapper ${jre}/bin/java $out/bin/${pname} \
|
||||
--add-flags "-jar $out/share/java/${pname}-${version}.jar"
|
||||
'';
|
||||
}
|
||||
```
|
||||
|
||||
> Our script produces a dependency on `jre` rather than `jdk` to restrict the runtime closure necessary to run the application.
|
||||
|
||||
This will give you an executable shell-script that launches your JAR with all the dependencies available.
|
||||
|
||||
```bash
|
||||
❯ tree $(nix-build --no-out-link runnable-jar.nix)
|
||||
/nix/store/8d4c3ibw8ynsn01ibhyqmc1zhzz75s26-maven-demo-1.0
|
||||
├── bin
|
||||
│ └── maven-demo
|
||||
├── repository -> /nix/store/g87va52nkc8jzbmi1aqdcf2f109r4dvn-maven-repository
|
||||
└── share
|
||||
└── java
|
||||
└── maven-demo-1.0.jar
|
||||
|
||||
❯ $(nix-build --no-out-link --option tarball-ttl 1 runnable-jar.nix)/bin/maven-demo
|
||||
NixOS 😀 is super cool 😃!
|
||||
```
|
|
@ -153,7 +153,7 @@ The dot product of [1 2] and [3 4] is: 11
|
|||
But if we maintain the script ourselves, and if there are more dependencies, it
|
||||
may be nice to encode those dependencies in source to make the script re-usable
|
||||
without that bit of knowledge. That can be done by using `nix-shell` as a
|
||||
[shebang](https://en.wikipedia.org/wiki/Shebang_(Unix), like so:
|
||||
[shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)), like so:
|
||||
|
||||
```python
|
||||
#!/usr/bin/env nix-shell
|
||||
|
|
|
@ -1,74 +1,38 @@
|
|||
---
|
||||
title: Ruby
|
||||
author: Michael Fellinger
|
||||
date: 2019-05-23
|
||||
---
|
||||
# Ruby {#sec-language-ruby}
|
||||
|
||||
# Ruby
|
||||
## Using Ruby
|
||||
|
||||
## User Guide
|
||||
Several versions of Ruby interpreters are available on Nix, as well as over 250 gems and many applications written in Ruby. The attribute `ruby` refers to the default Ruby interpreter, which is currently MRI 2.6. It's also possible to refer to specific versions, e.g. `ruby_2_y`, `jruby`, or `mruby`.
|
||||
|
||||
### Using Ruby
|
||||
In the Nixpkgs tree, Ruby packages can be found throughout, depending on what they do, and are called from the main package set. Ruby gems, however are separate sets, and there's one default set for each interpreter (currently MRI only).
|
||||
|
||||
#### Overview
|
||||
There are two main approaches for using Ruby with gems. One is to use a specifically locked `Gemfile` for an application that has very strict dependencies. The other is to depend on the common gems, which we'll explain further down, and rely on them being updated regularly.
|
||||
|
||||
Several versions of Ruby interpreters are available on Nix, as well as over 250 gems and many applications written in Ruby.
|
||||
The attribute `ruby` refers to the default Ruby interpreter, which is currently
|
||||
MRI 2.5. It's also possible to refer to specific versions, e.g. `ruby_2_6`, `jruby`, or `mruby`.
|
||||
The interpreters have common attributes, namely `gems`, and `withPackages`. So you can refer to `ruby.gems.nokogiri`, or `ruby_2_6.gems.nokogiri` to get the Nokogiri gem already compiled and ready to use.
|
||||
|
||||
In the nixpkgs tree, Ruby packages can be found throughout, depending on what
|
||||
they do, and are called from the main package set. Ruby gems, however are
|
||||
separate sets, and there's one default set for each interpreter (currently MRI
|
||||
only).
|
||||
Since not all gems have executables like `nokogiri`, it's usually more convenient to use the `withPackages` function like this: `ruby.withPackages (p: with p; [ nokogiri ])`. This will also make sure that the Ruby in your environment will be able to find the gem and it can be used in your Ruby code (for example via `ruby` or `irb` executables) via `require "nokogiri"` as usual.
|
||||
|
||||
There are two main approaches for using Ruby with gems.
|
||||
One is to use a specifically locked `Gemfile` for an application that has very strict dependencies.
|
||||
The other is to depend on the common gems, which we'll explain further down, and
|
||||
rely on them being updated regularly.
|
||||
### Temporary Ruby environment with `nix-shell`
|
||||
|
||||
The interpreters have common attributes, namely `gems`, and `withPackages`. So
|
||||
you can refer to `ruby.gems.nokogiri`, or `ruby_2_5.gems.nokogiri` to get the
|
||||
Nokogiri gem already compiled and ready to use.
|
||||
Rather than having a single Ruby environment shared by all Ruby development projects on a system, Nix allows you to create separate environments per project. `nix-shell` gives you the possibility to temporarily load another environment akin to a combined `chruby` or `rvm` and `bundle exec`.
|
||||
|
||||
Since not all gems have executables like `nokogiri`, it's usually more
|
||||
convenient to use the `withPackages` function like this:
|
||||
`ruby.withPackages (p: with p; [ nokogiri ])`. This will also make sure that the
|
||||
Ruby in your environment will be able to find the gem and it can be used in your
|
||||
Ruby code (for example via `ruby` or `irb` executables) via `require "nokogiri"`
|
||||
as usual.
|
||||
There are two methods for loading a shell with Ruby packages. The first and recommended method is to create an environment with `ruby.withPackages` and load that.
|
||||
|
||||
#### Temporary Ruby environment with `nix-shell`
|
||||
|
||||
Rather than having a single Ruby environment shared by all Ruby
|
||||
development projects on a system, Nix allows you to create separate
|
||||
environments per project. `nix-shell` gives you the possibility to
|
||||
temporarily load another environment akin to a combined `chruby` or
|
||||
`rvm` and `bundle exec`.
|
||||
|
||||
There are two methods for loading a shell with Ruby packages. The first and
|
||||
recommended method is to create an environment with `ruby.withPackages` and load
|
||||
that.
|
||||
|
||||
```shell
|
||||
nix-shell -p "ruby.withPackages (ps: with ps; [ nokogiri pry ])"
|
||||
```ShellSession
|
||||
$ nix-shell -p "ruby.withPackages (ps: with ps; [ nokogiri pry ])"
|
||||
```
|
||||
|
||||
The other method, which is not recommended, is to create an environment and list
|
||||
all the packages directly.
|
||||
The other method, which is not recommended, is to create an environment and list all the packages directly.
|
||||
|
||||
```shell
|
||||
nix-shell -p ruby.gems.nokogiri ruby.gems.pry
|
||||
```ShellSession
|
||||
$ nix-shell -p ruby.gems.nokogiri ruby.gems.pry
|
||||
```
|
||||
|
||||
Again, it's possible to launch the interpreter from the shell. The Ruby
|
||||
interpreter has the attribute `gems` which contains all Ruby gems for that
|
||||
specific interpreter.
|
||||
Again, it's possible to launch the interpreter from the shell. The Ruby interpreter has the attribute `gems` which contains all Ruby gems for that specific interpreter.
|
||||
|
||||
##### Load environment from `.nix` expression
|
||||
#### Load Ruby environment from `.nix` expression
|
||||
|
||||
As explained in the Nix manual, `nix-shell` can also load an expression from a
|
||||
`.nix` file. Say we want to have Ruby 2.5, `nokogori`, and `pry`. Consider a
|
||||
`shell.nix` file with:
|
||||
As explained in the Nix manual, `nix-shell` can also load an expression from a `.nix` file. Say we want to have Ruby 2.6, `nokogori`, and `pry`. Consider a `shell.nix` file with:
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
|
@ -77,43 +41,33 @@ ruby.withPackages (ps: with ps; [ nokogiri pry ])
|
|||
|
||||
What's happening here?
|
||||
|
||||
1. We begin with importing the Nix Packages collections. `import <nixpkgs>`
|
||||
imports the `<nixpkgs>` function, `{}` calls it and the `with` statement
|
||||
brings all attributes of `nixpkgs` in the local scope. These attributes form
|
||||
the main package set.
|
||||
1. We begin with importing the Nix Packages collections. `import <nixpkgs>` imports the `<nixpkgs>` function, `{}` calls it and the `with` statement brings all attributes of `nixpkgs` in the local scope. These attributes form the main package set.
|
||||
2. Then we create a Ruby environment with the `withPackages` function.
|
||||
3. The `withPackages` function expects us to provide a function as an argument
|
||||
that takes the set of all ruby gems and returns a list of packages to include
|
||||
in the environment. Here, we select the packages `nokogiri` and `pry` from
|
||||
the package set.
|
||||
3. The `withPackages` function expects us to provide a function as an argument that takes the set of all ruby gems and returns a list of packages to include in the environment. Here, we select the packages `nokogiri` and `pry` from the package set.
|
||||
|
||||
##### Execute command with `--run`
|
||||
#### Execute command with `--run`
|
||||
|
||||
A convenient flag for `nix-shell` is `--run`. It executes a command in the
|
||||
`nix-shell`. We can e.g. directly open a `pry` REPL:
|
||||
A convenient flag for `nix-shell` is `--run`. It executes a command in the `nix-shell`. We can e.g. directly open a `pry` REPL:
|
||||
|
||||
```shell
|
||||
nix-shell -p "ruby.withPackages (ps: with ps; [ nokogiri pry ])" --run "pry"
|
||||
```ShellSession
|
||||
$ nix-shell -p "ruby.withPackages (ps: with ps; [ nokogiri pry ])" --run "pry"
|
||||
```
|
||||
|
||||
Or immediately require `nokogiri` in pry:
|
||||
|
||||
```shell
|
||||
nix-shell -p "ruby.withPackages (ps: with ps; [ nokogiri pry ])" --run "pry -rnokogiri"
|
||||
```ShellSession
|
||||
$ nix-shell -p "ruby.withPackages (ps: with ps; [ nokogiri pry ])" --run "pry -rnokogiri"
|
||||
```
|
||||
|
||||
Or run a script using this environment:
|
||||
|
||||
```shell
|
||||
nix-shell -p "ruby.withPackages (ps: with ps; [ nokogiri pry ])" --run "ruby example.rb"
|
||||
```ShellSession
|
||||
$ nix-shell -p "ruby.withPackages (ps: with ps; [ nokogiri pry ])" --run "ruby example.rb"
|
||||
```
|
||||
|
||||
##### Using `nix-shell` as shebang
|
||||
#### Using `nix-shell` as shebang
|
||||
|
||||
In fact, for the last case, there is a more convenient method. You can add a
|
||||
[shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) to your script
|
||||
specifying which dependencies `nix-shell` needs. With the following shebang, you
|
||||
can just execute `./example.rb`, and it will run with all dependencies.
|
||||
In fact, for the last case, there is a more convenient method. You can add a [shebang](<https://en.wikipedia.org/wiki/Shebang_(Unix)>) to your script specifying which dependencies `nix-shell` needs. With the following shebang, you can just execute `./example.rb`, and it will run with all dependencies.
|
||||
|
||||
```ruby
|
||||
#! /usr/bin/env nix-shell
|
||||
|
@ -126,35 +80,24 @@ body = RestClient.get('http://example.com').body
|
|||
puts Nokogiri::HTML(body).at('h1').text
|
||||
```
|
||||
|
||||
### Developing with Ruby
|
||||
## Developing with Ruby
|
||||
|
||||
#### Using an existing Gemfile
|
||||
### Using an existing Gemfile
|
||||
|
||||
In most cases, you'll already have a `Gemfile.lock` listing all your dependencies.
|
||||
This can be used to generate a `gemset.nix` which is used to fetch the gems and
|
||||
combine them into a single environment.
|
||||
The reason why you need to have a separate file for this, is that Nix requires
|
||||
you to have a checksum for each input to your build.
|
||||
Since the `Gemfile.lock` that `bundler` generates doesn't provide us with
|
||||
checksums, we have to first download each gem, calculate its SHA256, and store
|
||||
it in this separate file.
|
||||
In most cases, you'll already have a `Gemfile.lock` listing all your dependencies. This can be used to generate a `gemset.nix` which is used to fetch the gems and combine them into a single environment. The reason why you need to have a separate file for this, is that Nix requires you to have a checksum for each input to your build. Since the `Gemfile.lock` that `bundler` generates doesn't provide us with checksums, we have to first download each gem, calculate its SHA256, and store it in this separate file.
|
||||
|
||||
So the steps from having just a `Gemfile` to a `gemset.nix` are:
|
||||
|
||||
```shell
|
||||
bundle lock
|
||||
bundix
|
||||
```ShellSession
|
||||
$ bundle lock
|
||||
$ bundix
|
||||
```
|
||||
|
||||
If you already have a `Gemfile.lock`, you can simply run `bundix` and it will
|
||||
work the same.
|
||||
If you already have a `Gemfile.lock`, you can simply run `bundix` and it will work the same.
|
||||
|
||||
To update the gems in your `Gemfile.lock`, you may use the `bundix -l` flag,
|
||||
which will create a new `Gemfile.lock` in case the `Gemfile` has a more recent
|
||||
time of modification.
|
||||
To update the gems in your `Gemfile.lock`, you may use the `bundix -l` flag, which will create a new `Gemfile.lock` in case the `Gemfile` has a more recent time of modification.
|
||||
|
||||
Once the `gemset.nix` is generated, it can be used in a
|
||||
`bundlerEnv` derivation. Here is an example you could use for your `shell.nix`:
|
||||
Once the `gemset.nix` is generated, it can be used in a `bundlerEnv` derivation. Here is an example you could use for your `shell.nix`:
|
||||
|
||||
```nix
|
||||
# ...
|
||||
|
@ -166,41 +109,26 @@ let
|
|||
in mkShell { buildInputs = [ gems gems.wrappedRuby ]; }
|
||||
```
|
||||
|
||||
With this file in your directory, you can run `nix-shell` to build and use the gems.
|
||||
The important parts here are `bundlerEnv` and `wrappedRuby`.
|
||||
With this file in your directory, you can run `nix-shell` to build and use the gems. The important parts here are `bundlerEnv` and `wrappedRuby`.
|
||||
|
||||
The `bundlerEnv` is a wrapper over all the gems in your gemset. This means that
|
||||
all the `/lib` and `/bin` directories will be available, and the executables of
|
||||
all gems (even of indirect dependencies) will end up in your `$PATH`.
|
||||
The `wrappedRuby` provides you with all executables that come with Ruby itself,
|
||||
but wrapped so they can easily find the gems in your gemset.
|
||||
The `bundlerEnv` is a wrapper over all the gems in your gemset. This means that all the `/lib` and `/bin` directories will be available, and the executables of all gems (even of indirect dependencies) will end up in your `$PATH`. The `wrappedRuby` provides you with all executables that come with Ruby itself, but wrapped so they can easily find the gems in your gemset.
|
||||
|
||||
One common issue that you might have is that you have Ruby 2.6, but also
|
||||
`bundler` in your gemset. That leads to a conflict for `/bin/bundle` and
|
||||
`/bin/bundler`. You can resolve this by wrapping either your Ruby or your gems
|
||||
in a `lowPrio` call. So in order to give the `bundler` from your gemset
|
||||
priority, it would be used like this:
|
||||
One common issue that you might have is that you have Ruby 2.6, but also `bundler` in your gemset. That leads to a conflict for `/bin/bundle` and `/bin/bundler`. You can resolve this by wrapping either your Ruby or your gems in a `lowPrio` call. So in order to give the `bundler` from your gemset priority, it would be used like this:
|
||||
|
||||
```nix
|
||||
# ...
|
||||
mkShell { buildInputs = [ gems (lowPrio gems.wrappedRuby) ]; }
|
||||
```
|
||||
|
||||
### Gem-specific configurations and workarounds
|
||||
|
||||
#### Gem-specific configurations and workarounds
|
||||
In some cases, especially if the gem has native extensions, you might need to modify the way the gem is built.
|
||||
|
||||
In some cases, especially if the gem has native extensions, you might need to
|
||||
modify the way the gem is built.
|
||||
This is done via a common configuration file that includes all of the workarounds for each gem.
|
||||
|
||||
This is done via a common configuration file that includes all of the
|
||||
workarounds for each gem.
|
||||
This file lives at `/pkgs/development/ruby-modules/gem-config/default.nix`, since it already contains a lot of entries, it should be pretty easy to add the modifications you need for your needs.
|
||||
|
||||
This file lives at `/pkgs/development/ruby-modules/gem-config/default.nix`,
|
||||
since it already contains a lot of entries, it should be pretty easy to add the
|
||||
modifications you need for your needs.
|
||||
|
||||
In the meanwhile, or if the modification is for a private gem, you can also add
|
||||
the configuration to only your own environment.
|
||||
In the meanwhile, or if the modification is for a private gem, you can also add the configuration to only your own environment.
|
||||
|
||||
Two places that allow this modification are the `ruby` derivation, or `bundlerEnv`.
|
||||
|
||||
|
@ -261,10 +189,9 @@ let
|
|||
in pkgs.ruby.withPackages (ps: with ps; [ pg ])
|
||||
```
|
||||
|
||||
Then we can get whichever postgresql version we desire and the `pg` gem will
|
||||
always reference it correctly:
|
||||
Then we can get whichever postgresql version we desire and the `pg` gem will always reference it correctly:
|
||||
|
||||
```shell
|
||||
```ShellSession
|
||||
$ nix-shell --argstr pg_version 9_4 --run 'ruby -rpg -e "puts PG.library_version"'
|
||||
90421
|
||||
|
||||
|
@ -272,24 +199,15 @@ $ nix-shell --run 'ruby -rpg -e "puts PG.library_version"'
|
|||
100007
|
||||
```
|
||||
|
||||
Of course for this use-case one could also use overlays since the configuration
|
||||
for `pg` depends on the `postgresql` alias, but for demonstration purposes this
|
||||
has to suffice.
|
||||
Of course for this use-case one could also use overlays since the configuration for `pg` depends on the `postgresql` alias, but for demonstration purposes this has to suffice.
|
||||
|
||||
#### Adding a gem to the default gemset
|
||||
### Adding a gem to the default gemset
|
||||
|
||||
Now that you know how to get a working Ruby environment with Nix, it's time to
|
||||
go forward and start actually developing with Ruby.
|
||||
We will first have a look at how Ruby gems are packaged on Nix. Then, we will
|
||||
look at how you can use development mode with your code.
|
||||
Now that you know how to get a working Ruby environment with Nix, it's time to go forward and start actually developing with Ruby. We will first have a look at how Ruby gems are packaged on Nix. Then, we will look at how you can use development mode with your code.
|
||||
|
||||
All gems in the standard set are automatically generated from a single
|
||||
`Gemfile`. The dependency resolution is done with `bundler` and makes it more
|
||||
likely that all gems are compatible to each other.
|
||||
All gems in the standard set are automatically generated from a single `Gemfile`. The dependency resolution is done with `bundler` and makes it more likely that all gems are compatible to each other.
|
||||
|
||||
In order to add a new gem to nixpkgs, you can put it into the
|
||||
`/pkgs/development/ruby-modules/with-packages/Gemfile` and run
|
||||
`./maintainers/scripts/update-ruby-packages`.
|
||||
In order to add a new gem to nixpkgs, you can put it into the `/pkgs/development/ruby-modules/with-packages/Gemfile` and run `./maintainers/scripts/update-ruby-packages`.
|
||||
|
||||
To test that it works, you can then try using the gem with:
|
||||
|
||||
|
@ -297,16 +215,11 @@ To test that it works, you can then try using the gem with:
|
|||
NIX_PATH=nixpkgs=$PWD nix-shell -p "ruby.withPackages (ps: with ps; [ name-of-your-gem ])"
|
||||
```
|
||||
|
||||
#### Packaging applications
|
||||
### Packaging applications
|
||||
|
||||
A common task is to add a ruby executable to nixpkgs, popular examples would be
|
||||
`chef`, `jekyll`, or `sass`. A good way to do that is to use the `bundlerApp`
|
||||
function, that allows you to make a package that only exposes the listed
|
||||
executables, otherwise the package may cause conflicts through common paths like
|
||||
`bin/rake` or `bin/bundler` that aren't meant to be used.
|
||||
A common task is to add a ruby executable to nixpkgs, popular examples would be `chef`, `jekyll`, or `sass`. A good way to do that is to use the `bundlerApp` function, that allows you to make a package that only exposes the listed executables, otherwise the package may cause conflicts through common paths like `bin/rake` or `bin/bundler` that aren't meant to be used.
|
||||
|
||||
The absolute easiest way to do that is to write a
|
||||
`Gemfile` along these lines:
|
||||
The absolute easiest way to do that is to write a `Gemfile` along these lines:
|
||||
|
||||
```ruby
|
||||
source 'https://rubygems.org' do
|
||||
|
@ -314,10 +227,7 @@ source 'https://rubygems.org' do
|
|||
end
|
||||
```
|
||||
|
||||
If you want to package a specific version, you can use the standard Gemfile
|
||||
syntax for that, e.g. `gem 'mdl', '0.5.0'`, but if you want the latest stable
|
||||
version anyway, it's easier to update by simply running the `bundle lock` and
|
||||
`bundix` steps again.
|
||||
If you want to package a specific version, you can use the standard Gemfile syntax for that, e.g. `gem 'mdl', '0.5.0'`, but if you want the latest stable version anyway, it's easier to update by simply running the `bundle lock` and `bundix` steps again.
|
||||
|
||||
Now you can also also make a `default.nix` that looks like this:
|
||||
|
||||
|
@ -331,20 +241,15 @@ bundlerApp {
|
|||
}
|
||||
```
|
||||
|
||||
All that's left to do is to generate the corresponding `Gemfile.lock` and
|
||||
`gemset.nix` as described above in the `Using an existing Gemfile` section.
|
||||
All that's left to do is to generate the corresponding `Gemfile.lock` and `gemset.nix` as described above in the `Using an existing Gemfile` section.
|
||||
|
||||
##### Packaging executables that require wrapping
|
||||
#### Packaging executables that require wrapping
|
||||
|
||||
Sometimes your app will depend on other executables at runtime, and tries to
|
||||
find it through the `PATH` environment variable.
|
||||
Sometimes your app will depend on other executables at runtime, and tries to find it through the `PATH` environment variable.
|
||||
|
||||
In this case, you can provide a `postBuild` hook to `bundlerApp` that wraps the
|
||||
gem in another script that prefixes the `PATH`.
|
||||
In this case, you can provide a `postBuild` hook to `bundlerApp` that wraps the gem in another script that prefixes the `PATH`.
|
||||
|
||||
Of course you could also make a custom `gemConfig` if you know exactly how to
|
||||
patch it, but it's usually much easier to maintain with a simple wrapper so the
|
||||
patch doesn't have to be adjusted for each version.
|
||||
Of course you could also make a custom `gemConfig` if you know exactly how to patch it, but it's usually much easier to maintain with a simple wrapper so the patch doesn't have to be adjusted for each version.
|
||||
|
||||
Here's another example:
|
||||
|
||||
|
|
|
@ -1,107 +0,0 @@
|
|||
<section xmlns="http://docbook.org/ns/docbook"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xml:id="sec-language-ruby">
|
||||
<title>Ruby</title>
|
||||
|
||||
<para>
|
||||
There currently is support to bundle applications that are packaged as Ruby gems. The utility "bundix" allows you to write a <filename>Gemfile</filename>, let bundler create a <filename>Gemfile.lock</filename>, and then convert this into a nix expression that contains all Gem dependencies automatically.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
For example, to package sensu, we did:
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
<prompt>$ </prompt>cd pkgs/servers/monitoring
|
||||
<prompt>$ </prompt>mkdir sensu
|
||||
<prompt>$ </prompt>cd sensu
|
||||
<prompt>$ </prompt>cat > Gemfile
|
||||
source 'https://rubygems.org'
|
||||
gem 'sensu'
|
||||
<prompt>$ </prompt>$(nix-build '<nixpkgs>' -A bundix --no-out-link)/bin/bundix --magic
|
||||
<prompt>$ </prompt>cat > default.nix
|
||||
{ lib, bundlerEnv, ruby }:
|
||||
|
||||
bundlerEnv rec {
|
||||
name = "sensu-${version}";
|
||||
|
||||
version = (import gemset).sensu.version;
|
||||
inherit ruby;
|
||||
# expects Gemfile, Gemfile.lock and gemset.nix in the same directory
|
||||
gemdir = ./.;
|
||||
|
||||
meta = with lib; {
|
||||
description = "A monitoring framework that aims to be simple, malleable, and scalable";
|
||||
homepage = "http://sensuapp.org/";
|
||||
license = with licenses; mit;
|
||||
maintainers = with maintainers; [ theuni ];
|
||||
platforms = platforms.unix;
|
||||
};
|
||||
}
|
||||
</screen>
|
||||
|
||||
<para>
|
||||
Please check in the <filename>Gemfile</filename>, <filename>Gemfile.lock</filename> and the <filename>gemset.nix</filename> so future updates can be run easily.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Updating Ruby packages can then be done like this:
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
<prompt>$ </prompt>cd pkgs/servers/monitoring/sensu
|
||||
<prompt>$ </prompt>nix-shell -p bundler --run 'bundle lock --update'
|
||||
<prompt>$ </prompt>nix-shell -p bundix --run 'bundix'
|
||||
</screen>
|
||||
|
||||
<para>
|
||||
For tools written in Ruby - i.e. where the desire is to install a package and then execute e.g. <command>rake</command> at the command line, there is an alternative builder called <literal>bundlerApp</literal>. Set up the <filename>gemset.nix</filename> the same way, and then, for example:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
<![CDATA[{ lib, bundlerApp }:
|
||||
|
||||
bundlerApp {
|
||||
pname = "corundum";
|
||||
gemdir = ./.;
|
||||
exes = [ "corundum-skel" ];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Tool and libraries for maintaining Ruby gems.";
|
||||
homepage = "https://github.com/nyarly/corundum";
|
||||
license = licenses.mit;
|
||||
maintainers = [ maintainers.nyarly ];
|
||||
platforms = platforms.unix;
|
||||
};
|
||||
}]]>
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
The chief advantage of <literal>bundlerApp</literal> over <literal>bundlerEnv</literal> is the executables introduced in the environment are precisely those selected in the <literal>exes</literal> list, as opposed to <literal>bundlerEnv</literal> which adds all the executables made available by gems in the gemset, which can mean e.g. <command>rspec</command> or <command>rake</command> in unpredictable versions available from various packages.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Resulting derivations for both builders also have two helpful attributes, <literal>env</literal> and <literal>wrappedRuby</literal>. The first one allows one to quickly drop into <command>nix-shell</command> with the specified environment present. E.g. <command>nix-shell -A sensu.env</command> would give you an environment with Ruby preset so it has all the libraries necessary for <literal>sensu</literal> in its paths. The second one can be used to make derivations from custom Ruby scripts which have <filename>Gemfile</filename>s with their dependencies specified. It is a derivation with <command>ruby</command> wrapped so it can find all the needed dependencies. For example, to make a derivation <literal>my-script</literal> for a <filename>my-script.rb</filename> (which should be placed in <filename>bin</filename>) you should run <command>bundix</command> as specified above and then use <literal>bundlerEnv</literal> like this:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
<![CDATA[let env = bundlerEnv {
|
||||
name = "my-script-env";
|
||||
|
||||
inherit ruby;
|
||||
gemfile = ./Gemfile;
|
||||
lockfile = ./Gemfile.lock;
|
||||
gemset = ./gemset.nix;
|
||||
};
|
||||
|
||||
in stdenv.mkDerivation {
|
||||
name = "my-script";
|
||||
buildInputs = [ env.wrappedRuby ];
|
||||
script = ./my-script.rb;
|
||||
buildCommand = ''
|
||||
install -D -m755 $script $out/bin/my-script
|
||||
patchShebangs $out/bin/my-script
|
||||
'';
|
||||
}]]>
|
||||
</programlisting>
|
||||
</section>
|
|
@ -16,9 +16,9 @@ cargo
|
|||
into the `environment.systemPackages` or bring them into
|
||||
scope with `nix-shell -p rustc cargo`.
|
||||
|
||||
For daily builds (beta and nightly) use either rustup from
|
||||
nixpkgs or use the [Rust nightlies
|
||||
overlay](#using-the-rust-nightlies-overlay).
|
||||
For other versions such as daily builds (beta and nightly),
|
||||
use either `rustup` from nixpkgs (which will manage the rust installation in your home directory),
|
||||
or use Mozilla's [Rust nightlies overlay](#using-the-rust-nightlies-overlay).
|
||||
|
||||
## Compiling Rust applications with Cargo
|
||||
|
||||
|
@ -530,8 +530,15 @@ Mozilla provides an overlay for nixpkgs to bring a nightly version of Rust into
|
|||
This overlay can _also_ be used to install recent unstable or stable versions
|
||||
of Rust, if desired.
|
||||
|
||||
To use this overlay, clone
|
||||
[nixpkgs-mozilla](https://github.com/mozilla/nixpkgs-mozilla),
|
||||
### Rust overlay installation
|
||||
|
||||
You can use this overlay by either changing your local nixpkgs configuration,
|
||||
or by adding the overlay declaratively in a nix expression, e.g. in `configuration.nix`.
|
||||
For more information see [#sec-overlays-install](the manual on installing overlays).
|
||||
|
||||
#### Imperative rust overlay installation
|
||||
|
||||
Clone [nixpkgs-mozilla](https://github.com/mozilla/nixpkgs-mozilla),
|
||||
and create a symbolic link to the file
|
||||
[rust-overlay.nix](https://github.com/mozilla/nixpkgs-mozilla/blob/master/rust-overlay.nix)
|
||||
in the `~/.config/nixpkgs/overlays` directory.
|
||||
|
@ -540,14 +547,42 @@ in the `~/.config/nixpkgs/overlays` directory.
|
|||
$ mkdir -p ~/.config/nixpkgs/overlays
|
||||
$ ln -s $(pwd)/nixpkgs-mozilla/rust-overlay.nix ~/.config/nixpkgs/overlays/rust-overlay.nix
|
||||
|
||||
The latest version can be installed with the following command:
|
||||
### Declarative rust overlay installation
|
||||
|
||||
$ nix-env -Ai nixos.latest.rustChannels.stable.rust
|
||||
Add the following to your `configuration.nix`, `home-configuration.nix`, `shell.nix`, or similar:
|
||||
|
||||
```
|
||||
nixpkgs = {
|
||||
overlays = [
|
||||
(import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz))
|
||||
# Further overlays go here
|
||||
];
|
||||
};
|
||||
```
|
||||
|
||||
Note that this will fetch the latest overlay version when rebuilding your system.
|
||||
|
||||
### Rust overlay usage
|
||||
|
||||
The overlay contains attribute sets corresponding to different versions of the rust toolchain, such as:
|
||||
|
||||
* `latest.rustChannels.stable`
|
||||
* `latest.rustChannels.nightly`
|
||||
* a function `rustChannelOf`, called as `(rustChannelOf { date = "2018-04-11"; channel = "nightly"; })`, or...
|
||||
* `(nixpkgs.rustChannelOf { rustToolchain = ./rust-toolchain; })` if you have a local `rust-toolchain` file (see https://github.com/mozilla/nixpkgs-mozilla#using-in-nix-expressions for an example)
|
||||
|
||||
Each of these contain packages such as `rust`, which contains your usual rust development tools with the respective toolchain chosen.
|
||||
For example, you might want to add `latest.rustChannels.stable.rust` to the list of packages in your configuration.
|
||||
|
||||
Imperatively, the latest stable version can be installed with the following command:
|
||||
|
||||
$ nix-env -Ai nixpkgs.latest.rustChannels.stable.rust
|
||||
|
||||
Or using the attribute with nix-shell:
|
||||
|
||||
$ nix-shell -p nixos.latest.rustChannels.stable.rust
|
||||
$ nix-shell -p nixpkgs.latest.rustChannels.stable.rust
|
||||
|
||||
Substitute the `nixpkgs` prefix with `nixos` on NixOS.
|
||||
To install the beta or nightly channel, "stable" should be substituted by
|
||||
"nightly" or "beta", or
|
||||
use the function provided by this overlay to pull a version based on a
|
||||
|
|
|
@ -189,8 +189,7 @@ hello-2.3 A program that produces a familiar, friendly greeting
|
|||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
A list of names and e-mail addresses of the maintainers of this Nix expression. If you would like to be a maintainer of a package, you may want to add yourself to <link
|
||||
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/maintainers/maintainer-list.nix"><filename>nixpkgs/maintainers/maintainer-list.nix</filename></link> and write something like <literal>[ stdenv.lib.maintainers.alice stdenv.lib.maintainers.bob ]</literal>.
|
||||
A list of the maintainers of this Nix expression. Maintainers are defined in <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/maintainers/maintainer-list.nix"><filename>nixpkgs/maintainers/maintainer-list.nix</filename></link>. There is no restriction to becoming a maintainer, just add yourself to that list in a separate commit titled 'maintainers: add alice', and reference maintainers with <literal>maintainers = with lib.maintainers; [ alice bob ]</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
|
|
@ -2070,7 +2070,7 @@ nativeBuildInputs = [ breakpointHook ];
|
|||
The <literal>installManPage</literal> function takes one or more paths to manpages to install. The manpages must have a section suffix, and may optionally be compressed (with <literal>.gz</literal> suffix). This function will place them into the correct directory.
|
||||
</para>
|
||||
<para>
|
||||
The <literal>installShellCompletion</literal> function takes one or more paths to shell completion files. By default it will autodetect the shell type from the completion file extension, but you may also specify it by passing one of <literal>--bash</literal>, <literal>--fish</literal>, or <literal>--zsh</literal>. These flags apply to all paths listed after them (up until another shell flag is given). Each path may also have a custom installation name provided by providing a flag <literal>--name NAME</literal> before the path. If this flag is not provided, zsh completions will be renamed automatically such that <literal>foobar.zsh</literal> becomes <literal>_foobar</literal>.
|
||||
The <literal>installShellCompletion</literal> function takes one or more paths to shell completion files. By default it will autodetect the shell type from the completion file extension, but you may also specify it by passing one of <literal>--bash</literal>, <literal>--fish</literal>, or <literal>--zsh</literal>. These flags apply to all paths listed after them (up until another shell flag is given). Each path may also have a custom installation name provided by providing a flag <literal>--name NAME</literal> before the path. If this flag is not provided, zsh completions will be renamed automatically such that <literal>foobar.zsh</literal> becomes <literal>_foobar</literal>. A root name may be provided for all paths using the flag <literal>--cmd NAME</literal>; this synthesizes the appropriate name depending on the shell (e.g. <literal>--cmd foo</literal> will synthesize the name <literal>foo.bash</literal> for bash and <literal>_foo</literal> for zsh). The path may also be a fifo or named fd (such as produced by <literal><(cmd)</literal>), in which case the shell and name must be provided.
|
||||
<programlisting>
|
||||
nativeBuildInputs = [ installShellFiles ];
|
||||
postInstall = ''
|
||||
|
@ -2081,6 +2081,11 @@ postInstall = ''
|
|||
installShellCompletion --zsh --name _foobar share/completions.zsh
|
||||
# implicit behavior
|
||||
installShellCompletion share/completions/foobar.{bash,fish,zsh}
|
||||
# using named fd
|
||||
installShellCompletion --cmd foobar \
|
||||
--bash <($out/bin/foobar --bash-completion) \
|
||||
--fish <($out/bin/foobar --fish-completion) \
|
||||
--zsh <($out/bin/foobar --zsh-completion)
|
||||
'';
|
||||
</programlisting>
|
||||
</para>
|
||||
|
|
|
@ -169,6 +169,9 @@
|
|||
}
|
||||
</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
Note that <literal>whitelistedLicenses</literal> only applies to unfree licenses unless <literal>allowUnfree</literal> is enabled. It is not a generic whitelist for all types of licenses. <literal>blacklistedLicenses</literal> applies to all licenses.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
|
|
|
@ -217,4 +217,31 @@ rec {
|
|||
};
|
||||
in self;
|
||||
|
||||
/* Like the above, but aims to support cross compilation. It's still ugly, but
|
||||
hopefully it helps a little bit. */
|
||||
makeScopeWithSplicing = splicePackages: newScope: otherSplices: keep: f:
|
||||
let
|
||||
spliced = splicePackages {
|
||||
pkgsBuildBuild = otherSplices.selfBuildBuild;
|
||||
pkgsBuildHost = otherSplices.selfBuildHost;
|
||||
pkgsBuildTarget = otherSplices.selfBuildTarget;
|
||||
pkgsHostHost = otherSplices.selfHostHost;
|
||||
pkgsHostTarget = self; # Not `otherSplices.selfHostTarget`;
|
||||
pkgsTargetTarget = otherSplices.selfTargetTarget;
|
||||
} // keep self;
|
||||
self = f self // {
|
||||
newScope = scope: newScope (spliced // scope);
|
||||
callPackage = newScope spliced; # == self.newScope {};
|
||||
# N.B. the other stages of the package set spliced in are *not*
|
||||
# overridden.
|
||||
overrideScope = g: makeScopeWithSplicing
|
||||
splicePackages
|
||||
newScope
|
||||
otherSplices
|
||||
keep
|
||||
(lib.fixedPoints.extends g f);
|
||||
packages = f;
|
||||
};
|
||||
in self;
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
let
|
||||
|
||||
inherit (import ./fixed-points.nix {}) makeExtensible;
|
||||
inherit (import ./fixed-points.nix { inherit lib; }) makeExtensible;
|
||||
|
||||
lib = makeExtensible (self: let
|
||||
callLibs = file: import file { lib = self; };
|
||||
|
@ -69,7 +69,7 @@ let
|
|||
importJSON importTOML warn info showWarnings nixpkgsVersion version mod compare
|
||||
splitByAndCompare functionArgs setFunctionArgs isFunction toHexString toBaseDigits;
|
||||
inherit (self.fixedPoints) fix fix' converge extends composeExtensions
|
||||
makeExtensible makeExtensibleWithCustomName;
|
||||
composeManyExtensions makeExtensible makeExtensibleWithCustomName;
|
||||
inherit (self.attrsets) attrByPath hasAttrByPath setAttrByPath
|
||||
getAttrFromPath attrVals attrValues getAttrs catAttrs filterAttrs
|
||||
filterAttrsRecursive foldAttrs collect nameValuePair mapAttrs
|
||||
|
@ -101,7 +101,7 @@ let
|
|||
noDepEntry fullDepEntry packEntry stringAfter;
|
||||
inherit (self.customisation) overrideDerivation makeOverridable
|
||||
callPackageWith callPackagesWith extendDerivation hydraJob
|
||||
makeScope;
|
||||
makeScope makeScopeWithSplicing;
|
||||
inherit (self.meta) addMetaAttrs dontDistribute setName updateName
|
||||
appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
|
||||
hiPrioSet;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ ... }:
|
||||
{ lib, ... }:
|
||||
rec {
|
||||
# Compute the fixed point of the given function `f`, which is usually an
|
||||
# attribute set that expects its final, non-recursive representation as an
|
||||
|
@ -77,6 +77,15 @@ rec {
|
|||
super' = super // fApplied;
|
||||
in fApplied // g self super';
|
||||
|
||||
# Compose several extending functions of the type expected by 'extends' into
|
||||
# one where changes made in preceding functions are made available to
|
||||
# subsequent ones.
|
||||
#
|
||||
# composeManyExtensions : [packageSet -> packageSet -> packageSet] -> packageSet -> packageSet -> packageSet
|
||||
# ^final ^prev ^overrides ^final ^prev ^overrides
|
||||
composeManyExtensions =
|
||||
lib.foldr (x: y: composeExtensions x y) (self: super: {});
|
||||
|
||||
# Create an overridable, recursive attribute set. For example:
|
||||
#
|
||||
# nix-repl> obj = makeExtensible (self: { })
|
||||
|
|
|
@ -392,6 +392,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||
fullName = "Historic Permission Notice and Disclaimer";
|
||||
};
|
||||
|
||||
hpndSellVariant = spdx {
|
||||
fullName = "Historical Permission Notice and Disclaimer - sell variant";
|
||||
spdxId = "HPND-sell-variant";
|
||||
};
|
||||
|
||||
# Intel's license, seems free
|
||||
iasl = {
|
||||
fullName = "iASL";
|
||||
|
|
|
@ -640,13 +640,7 @@ rec {
|
|||
unique [ 3 2 3 4 ]
|
||||
=> [ 3 2 4 ]
|
||||
*/
|
||||
unique = list:
|
||||
if list == [] then
|
||||
[]
|
||||
else
|
||||
let
|
||||
x = head list;
|
||||
in [x] ++ unique (remove x list);
|
||||
unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) [];
|
||||
|
||||
/* Intersects list 'e' and another list. O(nm) complexity.
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ let
|
|||
hasContext
|
||||
match
|
||||
readDir
|
||||
split
|
||||
storeDir
|
||||
tryEval
|
||||
;
|
||||
|
@ -15,7 +16,6 @@ let
|
|||
isString
|
||||
pathExists
|
||||
readFile
|
||||
split
|
||||
;
|
||||
in
|
||||
rec {
|
||||
|
|
|
@ -561,7 +561,9 @@ rec {
|
|||
enableFeature false "shared"
|
||||
=> "--disable-shared"
|
||||
*/
|
||||
enableFeature = enable: feat: "--${if enable then "enable" else "disable"}-${feat}";
|
||||
enableFeature = enable: feat:
|
||||
assert isString feat; # e.g. passing openssl instead of "openssl"
|
||||
"--${if enable then "enable" else "disable"}-${feat}";
|
||||
|
||||
/* Create an --{enable-<feat>=<value>,disable-<feat>} string that can be passed to
|
||||
standard GNU Autoconf scripts.
|
||||
|
@ -583,7 +585,9 @@ rec {
|
|||
withFeature false "shared"
|
||||
=> "--without-shared"
|
||||
*/
|
||||
withFeature = with_: feat: "--${if with_ then "with" else "without"}-${feat}";
|
||||
withFeature = with_: feat:
|
||||
assert isString feat; # e.g. passing openssl instead of "openssl"
|
||||
"--${if with_ then "with" else "without"}-${feat}";
|
||||
|
||||
/* Create an --{with-<feat>=<value>,without-<feat>} string that can be passed to
|
||||
standard GNU Autoconf scripts.
|
||||
|
|
|
@ -35,6 +35,9 @@ let
|
|||
"msp430-none"
|
||||
"riscv64-none" "riscv32-none"
|
||||
"vc4-none"
|
||||
"or1k-none"
|
||||
|
||||
"mmix-mmixware"
|
||||
|
||||
"js-ghcjs"
|
||||
|
||||
|
@ -56,8 +59,10 @@ in {
|
|||
i686 = filterDoubles predicates.isi686;
|
||||
x86_64 = filterDoubles predicates.isx86_64;
|
||||
mips = filterDoubles predicates.isMips;
|
||||
mmix = filterDoubles predicates.isMmix;
|
||||
riscv = filterDoubles predicates.isRiscV;
|
||||
vc4 = filterDoubles predicates.isVc4;
|
||||
or1k = filterDoubles predicates.isOr1k;
|
||||
js = filterDoubles predicates.isJavaScript;
|
||||
|
||||
bigEndian = filterDoubles predicates.isBigEndian;
|
||||
|
|
|
@ -34,6 +34,11 @@ rec {
|
|||
platform = platforms.raspberrypi;
|
||||
};
|
||||
|
||||
remarkable1 = {
|
||||
config = "armv7l-unknown-linux-gnueabihf";
|
||||
platform = platforms.zero-gravitas;
|
||||
};
|
||||
|
||||
armv7l-hf-multiplatform = {
|
||||
config = "armv7l-unknown-linux-gnueabihf";
|
||||
platform = platforms.armv7l-hf-multiplatform;
|
||||
|
@ -109,6 +114,11 @@ rec {
|
|||
platform = platforms.riscv-multiplatform "32";
|
||||
};
|
||||
|
||||
mmix = {
|
||||
config = "mmix-unknown-mmixware";
|
||||
libc = "newlib";
|
||||
};
|
||||
|
||||
msp430 = {
|
||||
config = "msp430-elf";
|
||||
libc = "newlib";
|
||||
|
@ -124,6 +134,12 @@ rec {
|
|||
platform = {};
|
||||
};
|
||||
|
||||
or1k = {
|
||||
config = "or1k-elf";
|
||||
libc = "newlib";
|
||||
platform = {};
|
||||
};
|
||||
|
||||
arm-embedded = {
|
||||
config = "arm-none-eabi";
|
||||
libc = "newlib";
|
||||
|
|
|
@ -17,6 +17,7 @@ rec {
|
|||
isAarch32 = { cpu = { family = "arm"; bits = 32; }; };
|
||||
isAarch64 = { cpu = { family = "arm"; bits = 64; }; };
|
||||
isMips = { cpu = { family = "mips"; }; };
|
||||
isMmix = { cpu = { family = "mmix"; }; };
|
||||
isRiscV = { cpu = { family = "riscv"; }; };
|
||||
isSparc = { cpu = { family = "sparc"; }; };
|
||||
isWasm = { cpu = { family = "wasm"; }; };
|
||||
|
@ -24,6 +25,7 @@ rec {
|
|||
isVc4 = { cpu = { family = "vc4"; }; };
|
||||
isAvr = { cpu = { family = "avr"; }; };
|
||||
isAlpha = { cpu = { family = "alpha"; }; };
|
||||
isOr1k = { cpu = { family = "or1k"; }; };
|
||||
isJavaScript = { cpu = cpuTypes.js; };
|
||||
|
||||
is32bit = { cpu = { bits = 32; }; };
|
||||
|
|
|
@ -93,6 +93,8 @@ rec {
|
|||
mips64 = { bits = 64; significantByte = bigEndian; family = "mips"; };
|
||||
mips64el = { bits = 64; significantByte = littleEndian; family = "mips"; };
|
||||
|
||||
mmix = { bits = 64; significantByte = bigEndian; family = "mmix"; };
|
||||
|
||||
powerpc = { bits = 32; significantByte = bigEndian; family = "power"; };
|
||||
powerpc64 = { bits = 64; significantByte = bigEndian; family = "power"; };
|
||||
powerpc64le = { bits = 64; significantByte = littleEndian; family = "power"; };
|
||||
|
@ -114,6 +116,8 @@ rec {
|
|||
|
||||
vc4 = { bits = 32; significantByte = littleEndian; family = "vc4"; };
|
||||
|
||||
or1k = { bits = 32; significantByte = bigEndian; family = "or1k"; };
|
||||
|
||||
js = { bits = 32; significantByte = littleEndian; family = "js"; };
|
||||
};
|
||||
|
||||
|
@ -268,19 +272,20 @@ rec {
|
|||
kernels = with execFormats; with kernelFamilies; setTypes types.openKernel {
|
||||
# TODO(@Ericson2314): Don't want to mass-rebuild yet to keeping 'darwin' as
|
||||
# the nnormalized name for macOS.
|
||||
macos = { execFormat = macho; families = { inherit darwin; }; name = "darwin"; };
|
||||
ios = { execFormat = macho; families = { inherit darwin; }; };
|
||||
freebsd = { execFormat = elf; families = { inherit bsd; }; };
|
||||
linux = { execFormat = elf; families = { }; };
|
||||
netbsd = { execFormat = elf; families = { inherit bsd; }; };
|
||||
none = { execFormat = unknown; families = { }; };
|
||||
openbsd = { execFormat = elf; families = { inherit bsd; }; };
|
||||
solaris = { execFormat = elf; families = { }; };
|
||||
wasi = { execFormat = wasm; families = { }; };
|
||||
redox = { execFormat = elf; families = { }; };
|
||||
windows = { execFormat = pe; families = { }; };
|
||||
ghcjs = { execFormat = unknown; families = { }; };
|
||||
genode = { execFormat = elf; families = { }; };
|
||||
macos = { execFormat = macho; families = { inherit darwin; }; name = "darwin"; };
|
||||
ios = { execFormat = macho; families = { inherit darwin; }; };
|
||||
freebsd = { execFormat = elf; families = { inherit bsd; }; };
|
||||
linux = { execFormat = elf; families = { }; };
|
||||
netbsd = { execFormat = elf; families = { inherit bsd; }; };
|
||||
none = { execFormat = unknown; families = { }; };
|
||||
openbsd = { execFormat = elf; families = { inherit bsd; }; };
|
||||
solaris = { execFormat = elf; families = { }; };
|
||||
wasi = { execFormat = wasm; families = { }; };
|
||||
redox = { execFormat = elf; families = { }; };
|
||||
windows = { execFormat = pe; families = { }; };
|
||||
ghcjs = { execFormat = unknown; families = { }; };
|
||||
genode = { execFormat = elf; families = { }; };
|
||||
mmixware = { execFormat = unknown; families = { }; };
|
||||
} // { # aliases
|
||||
# 'darwin' is the kernel for all of them. We choose macOS by default.
|
||||
darwin = kernels.macos;
|
||||
|
@ -382,7 +387,7 @@ rec {
|
|||
else if (elemAt l 1) == "elf"
|
||||
then { cpu = elemAt l 0; vendor = "unknown"; kernel = "none"; abi = elemAt l 1; }
|
||||
else { cpu = elemAt l 0; kernel = elemAt l 1; };
|
||||
"3" = # Awkwards hacks, beware!
|
||||
"3" = # Awkward hacks, beware!
|
||||
if elemAt l 1 == "apple"
|
||||
then { cpu = elemAt l 0; vendor = "apple"; kernel = elemAt l 2; }
|
||||
else if (elemAt l 1 == "linux") || (elemAt l 2 == "gnu")
|
||||
|
@ -393,6 +398,8 @@ rec {
|
|||
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "wasi"; }
|
||||
else if (elemAt l 2 == "redox")
|
||||
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "redox"; }
|
||||
else if (elemAt l 2 == "mmixware")
|
||||
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "mmixware"; }
|
||||
else if hasPrefix "netbsd" (elemAt l 2)
|
||||
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; }
|
||||
else if (elem (elemAt l 2) ["eabi" "eabihf" "elf"])
|
||||
|
|
|
@ -203,6 +203,20 @@ rec {
|
|||
# Legacy attribute, for compatibility with existing configs only.
|
||||
raspberrypi2 = armv7l-hf-multiplatform;
|
||||
|
||||
zero-gravitas = {
|
||||
name = "zero-gravitas";
|
||||
kernelBaseConfig = "zero-gravitas_defconfig";
|
||||
kernelArch = "arm";
|
||||
# kernelTarget verified by checking /boot on reMarkable 1 device
|
||||
kernelTarget = "zImage";
|
||||
kernelAutoModules = false;
|
||||
kernelDTB = true;
|
||||
gcc = {
|
||||
fpu = "neon";
|
||||
cpu = "cortex-a9";
|
||||
};
|
||||
};
|
||||
|
||||
scaleway-c1 = armv7l-hf-multiplatform // {
|
||||
gcc = {
|
||||
cpu = "cortex-a9";
|
||||
|
|
|
@ -87,6 +87,26 @@ runTests {
|
|||
expected = true;
|
||||
};
|
||||
|
||||
testComposeManyExtensions0 = {
|
||||
expr = let obj = makeExtensible (self: { foo = true; });
|
||||
emptyComposition = composeManyExtensions [];
|
||||
composed = obj.extend emptyComposition;
|
||||
in composed.foo;
|
||||
expected = true;
|
||||
};
|
||||
|
||||
testComposeManyExtensions =
|
||||
let f = self: super: { bar = false; baz = true; };
|
||||
g = self: super: { bar = super.baz or false; };
|
||||
h = self: super: { qux = super.bar or false; };
|
||||
obj = makeExtensible (self: { foo = self.qux; });
|
||||
in {
|
||||
expr = let composition = composeManyExtensions [f g h];
|
||||
composed = obj.extend composition;
|
||||
in composed.foo;
|
||||
expected = (obj.extend (composeExtensions f (composeExtensions g h))).foo;
|
||||
};
|
||||
|
||||
testBitAnd = {
|
||||
expr = (bitAnd 3 10);
|
||||
expected = 2;
|
||||
|
|
|
@ -11,12 +11,14 @@ let
|
|||
expr = lib.sort lib.lessThan x;
|
||||
expected = lib.sort lib.lessThan y;
|
||||
};
|
||||
in with lib.systems.doubles; lib.runTests {
|
||||
testall = mseteq all (linux ++ darwin ++ freebsd ++ openbsd ++ netbsd ++ illumos ++ wasi ++ windows ++ embedded ++ js ++ genode ++ redox);
|
||||
in
|
||||
with lib.systems.doubles; lib.runTests {
|
||||
testall = mseteq all (linux ++ darwin ++ freebsd ++ openbsd ++ netbsd ++ illumos ++ wasi ++ windows ++ embedded ++ mmix ++ js ++ genode ++ redox);
|
||||
|
||||
testarm = mseteq arm [ "armv5tel-linux" "armv6l-linux" "armv6l-none" "armv7a-linux" "armv7l-linux" "arm-none" "armv7a-darwin" ];
|
||||
testi686 = mseteq i686 [ "i686-linux" "i686-freebsd" "i686-genode" "i686-netbsd" "i686-openbsd" "i686-cygwin" "i686-windows" "i686-none" "i686-darwin" ];
|
||||
testmips = mseteq mips [ "mipsel-linux" ];
|
||||
testmmix = mseteq mmix [ "mmix-mmixware" ];
|
||||
testx86_64 = mseteq x86_64 [ "x86_64-linux" "x86_64-darwin" "x86_64-freebsd" "x86_64-genode" "x86_64-redox" "x86_64-openbsd" "x86_64-netbsd" "x86_64-cygwin" "x86_64-solaris" "x86_64-windows" "x86_64-none" ];
|
||||
|
||||
testcygwin = mseteq cygwin [ "i686-cygwin" "x86_64-cygwin" ];
|
||||
|
|
|
@ -514,6 +514,12 @@
|
|||
githubId = 69135;
|
||||
name = "Andrea Bedini";
|
||||
};
|
||||
andreasfelix = {
|
||||
email = "fandreas@physik.hu-berlin.de";
|
||||
github = "andreasfelix";
|
||||
githubId = 24651767;
|
||||
name = "Felix Andreas";
|
||||
};
|
||||
andres = {
|
||||
email = "ksnixos@andres-loeh.de";
|
||||
github = "kosmikus";
|
||||
|
@ -1146,9 +1152,9 @@
|
|||
githubId = 50839;
|
||||
name = "Brian Jones";
|
||||
};
|
||||
boothead = {
|
||||
commandodev = {
|
||||
email = "ben@perurbis.com";
|
||||
github = "boothead";
|
||||
github = "commandodev";
|
||||
githubId = 87764;
|
||||
name = "Ben Ford";
|
||||
};
|
||||
|
@ -1212,6 +1218,16 @@
|
|||
githubId = 5525646;
|
||||
name = "Brice Waegeneire";
|
||||
};
|
||||
Br1ght0ne = {
|
||||
email = "brightone@protonmail.com";
|
||||
github = "Br1ght0ne";
|
||||
githubId = 12615679;
|
||||
name = "Oleksii Filonenko";
|
||||
keys = [{
|
||||
longkeyid = "rsa3072/0xA1BC8428323ECFE8";
|
||||
fingerprint = "F549 3B7F 9372 5578 FDD3 D0B8 A1BC 8428 323E CFE8";
|
||||
}];
|
||||
};
|
||||
bsima = {
|
||||
email = "ben@bsima.me";
|
||||
github = "bsima";
|
||||
|
@ -1266,6 +1282,12 @@
|
|||
githubId = 7214361;
|
||||
name = "Roman Gerasimenko";
|
||||
};
|
||||
bburdette = {
|
||||
email = "bburdette@protonmail.com";
|
||||
github = "bburdette";
|
||||
githubId = 157330;
|
||||
name = "Ben Burdette";
|
||||
};
|
||||
bzizou = {
|
||||
email = "Bruno@bzizou.net";
|
||||
github = "bzizou";
|
||||
|
@ -1733,6 +1755,12 @@
|
|||
githubId = 1740337;
|
||||
name = "Chris Ostrouchov";
|
||||
};
|
||||
confus = {
|
||||
email = "con-f-use@gmx.net";
|
||||
github = "con-f-use";
|
||||
githubId = 11145016;
|
||||
name = "J.C.";
|
||||
};
|
||||
contrun = {
|
||||
email = "uuuuuu@protonmail.com";
|
||||
github = "contrun";
|
||||
|
@ -2011,6 +2039,16 @@
|
|||
githubId = 49904992;
|
||||
name = "Dawid Sowa";
|
||||
};
|
||||
dbirks = {
|
||||
email = "david@birks.dev";
|
||||
github = "dbirks";
|
||||
githubId = 7545665;
|
||||
name = "David Birks";
|
||||
keys = [{
|
||||
longkeyid = "ed25519/0xBB999F83D9A19A36";
|
||||
fingerprint = "B26F 9AD8 DA20 3392 EF87 C61A BB99 9F83 D9A1 9A36";
|
||||
}];
|
||||
};
|
||||
dbohdan = {
|
||||
email = "dbohdan@dbohdan.com";
|
||||
github = "dbohdan";
|
||||
|
@ -2827,6 +2865,12 @@
|
|||
fingerprint = "50B7 11F4 3DFD 2018 DCE6 E8D0 8A52 A140 BEBF 7D2C";
|
||||
}];
|
||||
};
|
||||
fabianhjr = {
|
||||
email = "fabianhjr@protonmail.com";
|
||||
github = "fabianhjr";
|
||||
githubId = 303897;
|
||||
name = "Fabián Heredia Montiel";
|
||||
};
|
||||
fadenb = {
|
||||
email = "tristan.helmich+nixos@gmail.com";
|
||||
github = "fadenb";
|
||||
|
@ -2879,16 +2923,6 @@
|
|||
githubId = 8182846;
|
||||
name = "Francesco Gazzetta";
|
||||
};
|
||||
filalex77 = {
|
||||
email = "brightone@protonmail.com";
|
||||
github = "filalex77";
|
||||
githubId = 12615679;
|
||||
name = "Oleksii Filonenko";
|
||||
keys = [{
|
||||
longkeyid = "rsa3072/0xA1BC8428323ECFE8";
|
||||
fingerprint = "F549 3B7F 9372 5578 FDD3 D0B8 A1BC 8428 323E CFE8";
|
||||
}];
|
||||
};
|
||||
fionera = {
|
||||
email = "nix@fionera.de";
|
||||
github = "fionera";
|
||||
|
@ -3165,12 +3199,6 @@
|
|||
githubId = 313929;
|
||||
name = "Gabriel Ebner";
|
||||
};
|
||||
genesis = {
|
||||
email = "ronan@aimao.org";
|
||||
github = "bignaux";
|
||||
githubId = 149484;
|
||||
name = "Ronan Bignaux";
|
||||
};
|
||||
georgewhewell = {
|
||||
email = "georgerw@gmail.com";
|
||||
github = "georgewhewell";
|
||||
|
@ -3283,6 +3311,16 @@
|
|||
githubId = 1621335;
|
||||
name = "Andrew Trachenko";
|
||||
};
|
||||
govanify = {
|
||||
name = "Gauvain 'GovanifY' Roussel-Tarbouriech";
|
||||
email = "gauvain@govanify.com";
|
||||
github = "govanify";
|
||||
githubId = 6375438;
|
||||
keys = [{
|
||||
longkeyid = "rsa4096/0xDE62E1E2A6145556";
|
||||
fingerprint = "5214 2D39 A7CE F8FA 872B CA7F DE62 E1E2 A614 5556";
|
||||
}];
|
||||
};
|
||||
gpyh = {
|
||||
email = "yacine.hmito@gmail.com";
|
||||
github = "yacinehmito";
|
||||
|
@ -3487,6 +3525,12 @@
|
|||
email = "t@larkery.com";
|
||||
name = "Tom Hinton";
|
||||
};
|
||||
hjones2199 = {
|
||||
email = "hjones2199@gmail.com";
|
||||
github = "hjones2199";
|
||||
githubId = 5525217;
|
||||
name = "Hunter Jones";
|
||||
};
|
||||
hkjn = {
|
||||
email = "me@hkjn.me";
|
||||
name = "Henrik Jonsson";
|
||||
|
@ -3859,6 +3903,8 @@
|
|||
};
|
||||
jcumming = {
|
||||
email = "jack@mudshark.org";
|
||||
github = "jcumming";
|
||||
githubId = 1982341;
|
||||
name = "Jack Cummings";
|
||||
};
|
||||
jD91mZM2 = {
|
||||
|
@ -4007,6 +4053,12 @@
|
|||
githubId = 2502736;
|
||||
name = "James Hillyerd";
|
||||
};
|
||||
jiehong = {
|
||||
email = "nixos@majiehong.com";
|
||||
github = "Jiehong";
|
||||
githubId = 1061229;
|
||||
name = "Jiehong Ma";
|
||||
};
|
||||
jirkamarsik = {
|
||||
email = "jiri.marsik89@gmail.com";
|
||||
github = "jirkamarsik";
|
||||
|
@ -4091,6 +4143,12 @@
|
|||
githubId = 60272884;
|
||||
name = "Jonathan Jeppener-Haltenhoff";
|
||||
};
|
||||
joelancaster = {
|
||||
email = "joe.a.lancas@gmail.com";
|
||||
github = "joelancaster";
|
||||
githubId = 16760945;
|
||||
name = "Joe Lancaster";
|
||||
};
|
||||
joelburget = {
|
||||
email = "joelburget@gmail.com";
|
||||
github = "joelburget";
|
||||
|
@ -4278,6 +4336,12 @@
|
|||
githubId = 16374374;
|
||||
name = "Joshua Campbell";
|
||||
};
|
||||
jshholland = {
|
||||
email = "josh@inv.alid.pw";
|
||||
github = "jshholland";
|
||||
githubId = 107689;
|
||||
name = "Josh Holland";
|
||||
};
|
||||
jtcoolen = {
|
||||
email = "jtcoolen@pm.me";
|
||||
name = "Julien Coolen";
|
||||
|
@ -4749,12 +4813,6 @@
|
|||
fingerprint = "5A9A 1C9B 2369 8049 3B48 CF5B 81A1 5409 4816 2372";
|
||||
}];
|
||||
};
|
||||
kylewlacy = {
|
||||
email = "kylelacy+nix@pm.me";
|
||||
github = "kylewlacy";
|
||||
githubId = 1362179;
|
||||
name = "Kyle Lacy";
|
||||
};
|
||||
laikq = {
|
||||
email = "gwen@quasebarth.de";
|
||||
github = "laikq";
|
||||
|
@ -4816,6 +4874,12 @@
|
|||
githubId = 20250323;
|
||||
name = "Lucio Delelis";
|
||||
};
|
||||
ldenefle = {
|
||||
email = "ldenefle@gmail.com";
|
||||
github = "ldenefle";
|
||||
githubId = 20558127;
|
||||
name = "Lucas Denefle";
|
||||
};
|
||||
ldesgoui = {
|
||||
email = "ldesgoui@gmail.com";
|
||||
github = "ldesgoui";
|
||||
|
@ -5268,6 +5332,12 @@
|
|||
githubId = 1238350;
|
||||
name = "Matthias Herrmann";
|
||||
};
|
||||
majesticmullet = {
|
||||
email = "hoccthomas@gmail.com.au";
|
||||
github = "MajesticMullet";
|
||||
githubId = 31056089;
|
||||
name = "Tom Ho";
|
||||
};
|
||||
makefu = {
|
||||
email = "makefu@syntax-fehler.de";
|
||||
github = "makefu";
|
||||
|
@ -5432,6 +5502,12 @@
|
|||
githubId = 1191859;
|
||||
name = "Maxim Krivchikov";
|
||||
};
|
||||
mazurel = {
|
||||
email = "mateusz.mazur@yahoo.com";
|
||||
github = "Mazurel";
|
||||
githubId = 22836301;
|
||||
name = "Mateusz Mazur";
|
||||
};
|
||||
mbakke = {
|
||||
email = "mbakke@fastmail.com";
|
||||
github = "mbakke";
|
||||
|
@ -5520,6 +5596,12 @@
|
|||
fingerprint = "D709 03C8 0BE9 ACDC 14F0 3BFB 77BF E531 397E DE94";
|
||||
}];
|
||||
};
|
||||
meatcar = {
|
||||
email = "nixpkgs@denys.me";
|
||||
github = "meatcar";
|
||||
githubId = 191622;
|
||||
name = "Denys Pavlov";
|
||||
};
|
||||
meditans = {
|
||||
email = "meditans@gmail.com";
|
||||
github = "meditans";
|
||||
|
@ -6059,6 +6141,12 @@
|
|||
githubId = 5139265;
|
||||
name = "James Wood";
|
||||
};
|
||||
mudrii = {
|
||||
email = "mudreac@gmail.com";
|
||||
github = "mudrii";
|
||||
githubId = 220262;
|
||||
name = "Ion Mudreac";
|
||||
};
|
||||
muflax = {
|
||||
email = "mail@muflax.com";
|
||||
github = "muflax";
|
||||
|
@ -6083,10 +6171,10 @@
|
|||
githubId = 6455574;
|
||||
name = "Matt Votava";
|
||||
};
|
||||
mwilsoninsight = {
|
||||
email = "max.wilson@insight.com";
|
||||
github = "mwilsoninsight";
|
||||
githubId = 47782621;
|
||||
maxwilson = {
|
||||
email = "nixpkgs@maxwilson.dev";
|
||||
github = "mwilsoncoding";
|
||||
githubId = 43796009;
|
||||
name = "Max Wilson";
|
||||
};
|
||||
myrl = {
|
||||
|
@ -6439,6 +6527,12 @@
|
|||
githubId = 167209;
|
||||
name = "Masanori Ogino";
|
||||
};
|
||||
omgbebebe = {
|
||||
email = "omgbebebe@gmail.com";
|
||||
github = "omgbebebe";
|
||||
githubId = 588167;
|
||||
name = "Sergey Bubnov";
|
||||
};
|
||||
omnipotententity = {
|
||||
email = "omnipotententity@gmail.com";
|
||||
github = "omnipotententity";
|
||||
|
@ -6613,6 +6707,12 @@
|
|||
githubId = 131844;
|
||||
name = "Igor Pashev";
|
||||
};
|
||||
pasqui23 = {
|
||||
email = "p3dimaria@hotmail.it";
|
||||
github = "pasqui23";
|
||||
githubId = 6931743;
|
||||
name = "pasqui23";
|
||||
};
|
||||
patryk27 = {
|
||||
email = "wychowaniec.patryk@gmail.com";
|
||||
github = "Patryk27";
|
||||
|
@ -6887,6 +6987,12 @@
|
|||
fingerprint = "240B 57DE 4271 2480 7CE3 EAC8 4F74 D536 1C4C A31E";
|
||||
}];
|
||||
};
|
||||
preisschild = {
|
||||
email = "florian@florianstroeger.com";
|
||||
github = "Preisschild";
|
||||
githubId = 11898437;
|
||||
name = "Florian Ströger";
|
||||
};
|
||||
priegger = {
|
||||
email = "philipp@riegger.name";
|
||||
github = "priegger";
|
||||
|
@ -7059,6 +7165,12 @@
|
|||
fingerprint = "7573 56D7 79BB B888 773E 415E 736C CDF9 EF51 BD97";
|
||||
}];
|
||||
};
|
||||
r-burns = {
|
||||
email = "rtburns@protonmail.com";
|
||||
github = "r-burns";
|
||||
githubId = 52847440;
|
||||
name = "Ryan Burns";
|
||||
};
|
||||
raboof = {
|
||||
email = "arnout@bzzt.net";
|
||||
github = "raboof";
|
||||
|
@ -7401,6 +7513,12 @@
|
|||
githubId = 1217934;
|
||||
name = "José Romildo Malaquias";
|
||||
};
|
||||
ronanmacf = {
|
||||
email = "macfhlar@tcd.ie";
|
||||
github = "ronanmacf";
|
||||
githubId = 25930627;
|
||||
name = "Ronan Mac Fhlannchadha";
|
||||
};
|
||||
rongcuid = {
|
||||
email = "rongcuid@outlook.com";
|
||||
github = "rongcuid";
|
||||
|
@ -8941,6 +9059,12 @@
|
|||
githubId = 619015;
|
||||
name = "Svintsov Dmitry";
|
||||
};
|
||||
urbas = {
|
||||
email = "matej.urbas@gmail.com";
|
||||
github = "urbas";
|
||||
githubId = 771193;
|
||||
name = "Matej Urbas";
|
||||
};
|
||||
uri-canva = {
|
||||
email = "uri@canva.com";
|
||||
github = "uri-canva";
|
||||
|
@ -9334,7 +9458,7 @@
|
|||
email = "worldofpeace@protonmail.ch";
|
||||
github = "worldofpeace";
|
||||
githubId = 28888242;
|
||||
name = "worldofpeace";
|
||||
name = "WORLDofPEACE";
|
||||
};
|
||||
wscott = {
|
||||
email = "wsc9tt@gmail.com";
|
||||
|
@ -9682,6 +9806,12 @@
|
|||
githubId = 10643;
|
||||
name = "Jason A. Donenfeld";
|
||||
};
|
||||
zyansheep = {
|
||||
email = "zyansheep@protonmail.com";
|
||||
github = "zyansheep";
|
||||
githubId = 20029431;
|
||||
name = "Zyansheep";
|
||||
};
|
||||
zzamboni = {
|
||||
email = "diego@zzamboni.org";
|
||||
github = "zzamboni";
|
||||
|
@ -9886,4 +10016,22 @@
|
|||
github = "wilsonehusin";
|
||||
githubId = 14004487;
|
||||
};
|
||||
bb2020 = {
|
||||
email = "bb2020@users.noreply.github.com";
|
||||
github = "bb2020";
|
||||
githubId = 19290397;
|
||||
name = "Tunc Uzlu";
|
||||
};
|
||||
pulsation = {
|
||||
name = "Philippe Sam-Long";
|
||||
email = "1838397+pulsation@users.noreply.github.com";
|
||||
github = "pulsation";
|
||||
githubId = 1838397;
|
||||
};
|
||||
zupo = {
|
||||
name = "Nejc Zupan";
|
||||
email = "nejczupan+nix@gmail.com";
|
||||
github = "zupo";
|
||||
githubId = 311580;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -9,3 +9,4 @@ curl https://repology.org/api/v1/repository/nix_unstable/problems \
|
|||
| jq -r '.[] | select(.type == "homepage_permanent_https_redirect") | .data | "s@\(.url)@\(.target)@"' \
|
||||
| sort | uniq | tee script.sed
|
||||
find -name '*.nix' | xargs -P4 -- sed -f script.sed -i
|
||||
rm script.sed
|
|
@ -108,4 +108,13 @@ with lib.maintainers; {
|
|||
];
|
||||
scope = "Maintain Podman and CRI-O related packages and modules.";
|
||||
};
|
||||
|
||||
sage = {
|
||||
members = [
|
||||
timokau
|
||||
omasanori
|
||||
raskin
|
||||
];
|
||||
scope = "Maintain SageMath and the dependencies that are likely to break it.";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<title>Service Management</title>
|
||||
<para>
|
||||
In NixOS, all system services are started and monitored using the systemd
|
||||
program. Systemd is the “init” process of the system (i.e. PID 1), the
|
||||
program. systemd is the “init” process of the system (i.e. PID 1), the
|
||||
parent of all other processes. It manages a set of so-called “units”,
|
||||
which can be things like system services (programs), but also mount points,
|
||||
swap files, devices, targets (groups of units) and more. Units can have
|
||||
|
@ -16,10 +16,17 @@
|
|||
dependencies of this unit cause all system services to be started, file
|
||||
systems to be mounted, swap files to be activated, and so on.
|
||||
</para>
|
||||
<para>
|
||||
The command <command>systemctl</command> is the main way to interact with
|
||||
<command>systemd</command>. Without any arguments, it shows the status of
|
||||
active units:
|
||||
<section xml:id="sect-nixos-systemd-general">
|
||||
<title>Interacting with a running systemd</title>
|
||||
<para>
|
||||
The command <command>systemctl</command> is the main way to interact with
|
||||
<command>systemd</command>. The following paragraphs demonstrate ways to
|
||||
interact with any OS running systemd as init system. NixOS is of no
|
||||
exception. The <link xlink:href="#sect-nixos-systemd-nixos">next section
|
||||
</link> explains NixOS specific things worth knowing.
|
||||
</para>
|
||||
<para>
|
||||
Without any arguments, <literal>systmctl</literal> the status of active units:
|
||||
<screen>
|
||||
<prompt>$ </prompt>systemctl
|
||||
-.mount loaded active mounted /
|
||||
|
@ -28,10 +35,10 @@ sshd.service loaded active running SSH Daemon
|
|||
graphical.target loaded active active Graphical Interface
|
||||
<replaceable>...</replaceable>
|
||||
</screen>
|
||||
</para>
|
||||
<para>
|
||||
You can ask for detailed status information about a unit, for instance, the
|
||||
PostgreSQL database service:
|
||||
</para>
|
||||
<para>
|
||||
You can ask for detailed status information about a unit, for instance, the
|
||||
PostgreSQL database service:
|
||||
<screen>
|
||||
<prompt>$ </prompt>systemctl status postgresql.service
|
||||
postgresql.service - PostgreSQL Server
|
||||
|
@ -62,11 +69,72 @@ Jan 07 15:55:57 hagbard systemd[1]: Started PostgreSQL Server.
|
|||
<prompt># </prompt>systemctl start postgresql.service
|
||||
<prompt># </prompt>systemctl restart postgresql.service
|
||||
</screen>
|
||||
These operations are synchronous: they wait until the service has finished
|
||||
starting or stopping (or has failed). Starting a unit will cause the
|
||||
dependencies of that unit to be started as well (if necessary).
|
||||
</para>
|
||||
<!-- - cgroups: each service and user session is a cgroup
|
||||
These operations are synchronous: they wait until the service has finished
|
||||
starting or stopping (or has failed). Starting a unit will cause the
|
||||
dependencies of that unit to be started as well (if necessary).
|
||||
</para>
|
||||
<!-- TODO: document cgroups, draft:
|
||||
each service and user session is a cgroup
|
||||
|
||||
- cgroup resource management -->
|
||||
- cgroup resource management -->
|
||||
</section>
|
||||
<section xml:id="sect-nixos-systemd-nixos">
|
||||
<title>systemd in NixOS</title>
|
||||
<para>
|
||||
Packages in Nixpkgs sometimes provide systemd units with them, usually in
|
||||
e.g <literal>#pkg-out#/lib/systemd/</literal>. Putting such a package in
|
||||
<literal>environment.systemPackages</literal> doesn't make the service
|
||||
available to users or the system.
|
||||
</para>
|
||||
<para>
|
||||
In order to enable a systemd <emphasis>system</emphasis> service with
|
||||
provided upstream package, use (e.g):
|
||||
<programlisting>
|
||||
<xref linkend="opt-systemd.packages"/> = [ pkgs.packagekit ];
|
||||
</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
Usually NixOS modules written by the community do the above, plus take care of
|
||||
other details. If a module was written for a service you are interested in,
|
||||
you'd probably need only to use
|
||||
<literal>services.#name#.enable = true;</literal>. These services are defined
|
||||
in Nixpkgs'
|
||||
<link xlink:href="https://github.com/NixOS/nixpkgs/tree/master/nixos/modules">
|
||||
<literal>nixos/modules/</literal> directory </link>. In case the service is
|
||||
simple enough, the above method should work, and start the service on boot.
|
||||
</para>
|
||||
<para>
|
||||
<emphasis>User</emphasis> systemd services on the other hand, should be
|
||||
treated differently. Given a package that has a systemd unit file at
|
||||
<literal>#pkg-out#/lib/systemd/user/</literal>, using
|
||||
<xref linkend="opt-systemd.packages"/> will make you able to start the service via
|
||||
<literal>systemctl --user start</literal>, but it won't start automatically on login.
|
||||
<!-- TODO: Document why systemd.packages doesn't work for user services or fix this.
|
||||
https://github.com/NixOS/nixpkgs/blob/2cd6594a8710a801038af2b72348658f732ce84a/nixos/modules/system/boot/systemd-lib.nix#L177-L198
|
||||
|
||||
This has been talked over at https://discourse.nixos.org/t/how-to-enable-upstream-systemd-user-services-declaratively/7649/5
|
||||
-->
|
||||
However, You can imperatively enable it by adding the package's attribute to
|
||||
<link linkend="opt-environment.systemPackages">
|
||||
<literal>systemd.packages</literal></link> and then do this (e.g):
|
||||
<screen>
|
||||
<prompt>$ </prompt>mkdir -p ~/.config/systemd/user/default.target.wants
|
||||
<prompt>$ </prompt>ln -s /run/current-system/sw/lib/systemd/user/syncthing.service ~/.config/systemd/user/default.target.wants/
|
||||
<prompt>$ </prompt>systemctl --user daemon-reload
|
||||
<prompt>$ </prompt>systemctl --user enable syncthing.service
|
||||
</screen>
|
||||
If you are interested in a timer file, use <literal>timers.target.wants</literal>
|
||||
instead of <literal>default.target.wants</literal> in the 1st and 2nd command.
|
||||
</para>
|
||||
<para>
|
||||
Using <literal>systemctl --user enable syncthing.service</literal> instead of
|
||||
the above, will work, but it'll use the absolute path of
|
||||
<literal>syncthing.service</literal> for the symlink, and this path is in
|
||||
<literal>/nix/store/.../lib/systemd/user/</literal>. Hence
|
||||
<link xlink:href="#sec-nix-gc">garbage collection</link> will remove that file
|
||||
and you will wind up with a broken symlink in your systemd configuration, which
|
||||
in turn will not make the service / timer start on login.
|
||||
</para>
|
||||
</section>
|
||||
</chapter>
|
||||
|
||||
|
|
|
@ -18,10 +18,12 @@
|
|||
<xi:include href="user-mgmt.xml" />
|
||||
<xi:include href="file-systems.xml" />
|
||||
<xi:include href="x-windows.xml" />
|
||||
<xi:include href="wayland.xml" />
|
||||
<xi:include href="gpu-accel.xml" />
|
||||
<xi:include href="xfce.xml" />
|
||||
<xi:include href="networking.xml" />
|
||||
<xi:include href="linux-kernel.xml" />
|
||||
<xi:include href="subversion.xml" />
|
||||
<xi:include href="../generated/modules.xml" xpointer="xpointer(//section[@id='modules']/*)" />
|
||||
<xi:include href="profiles.xml" />
|
||||
<xi:include href="kubernetes.xml" />
|
||||
|
|
|
@ -65,16 +65,16 @@ Platform Vendor Advanced Micro Devices, Inc.</screen>
|
|||
<title>AMD</title>
|
||||
|
||||
<para>
|
||||
Modern AMD <link
|
||||
xlink:href="https://en.wikipedia.org/wiki/Graphics_Core_Next">Graphics
|
||||
Core Next</link> (GCN) GPUs are supported through the
|
||||
<package>rocm-opencl-icd</package> package. Adding this package to
|
||||
<xref linkend="opt-hardware.opengl.extraPackages"/> enables OpenCL
|
||||
support:
|
||||
Modern AMD <link
|
||||
xlink:href="https://en.wikipedia.org/wiki/Graphics_Core_Next">Graphics
|
||||
Core Next</link> (GCN) GPUs are supported through the
|
||||
<package>rocm-opencl-icd</package> package. Adding this package to
|
||||
<xref linkend="opt-hardware.opengl.extraPackages"/> enables OpenCL
|
||||
support:
|
||||
|
||||
<programlisting><xref linkend="opt-hardware.opengl.extraPackages"/> = [
|
||||
rocm-opencl-icd
|
||||
];</programlisting>
|
||||
<programlisting><xref linkend="opt-hardware.opengl.extraPackages"/> = [
|
||||
rocm-opencl-icd
|
||||
];</programlisting>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
|
@ -100,9 +100,9 @@ Platform Vendor Advanced Micro Devices, Inc.</screen>
|
|||
support. For example, for Gen8 and later GPUs, the following
|
||||
configuration can be used:
|
||||
|
||||
<programlisting><xref linkend="opt-hardware.opengl.extraPackages"/> = [
|
||||
intel-compute-runtime
|
||||
];</programlisting>
|
||||
<programlisting><xref linkend="opt-hardware.opengl.extraPackages"/> = [
|
||||
intel-compute-runtime
|
||||
];</programlisting>
|
||||
|
||||
</para>
|
||||
</section>
|
||||
|
@ -173,31 +173,31 @@ GPU1:
|
|||
<title>AMD</title>
|
||||
|
||||
<para>
|
||||
Modern AMD <link
|
||||
xlink:href="https://en.wikipedia.org/wiki/Graphics_Core_Next">Graphics
|
||||
Core Next</link> (GCN) GPUs are supported through either radv, which is
|
||||
part of <package>mesa</package>, or the <package>amdvlk</package> package.
|
||||
Adding the <package>amdvlk</package> package to
|
||||
<xref linkend="opt-hardware.opengl.extraPackages"/> makes both drivers
|
||||
available for applications and lets them choose. A specific driver can
|
||||
be forced as follows:
|
||||
Modern AMD <link
|
||||
xlink:href="https://en.wikipedia.org/wiki/Graphics_Core_Next">Graphics
|
||||
Core Next</link> (GCN) GPUs are supported through either radv, which is
|
||||
part of <package>mesa</package>, or the <package>amdvlk</package> package.
|
||||
Adding the <package>amdvlk</package> package to
|
||||
<xref linkend="opt-hardware.opengl.extraPackages"/> makes both drivers
|
||||
available for applications and lets them choose. A specific driver can
|
||||
be forced as follows:
|
||||
|
||||
<programlisting><xref linkend="opt-hardware.opengl.extraPackages"/> = [
|
||||
pkgs.<package>amdvlk</package>
|
||||
];
|
||||
<programlisting><xref linkend="opt-hardware.opengl.extraPackages"/> = [
|
||||
pkgs.<package>amdvlk</package>
|
||||
];
|
||||
|
||||
# To enable Vulkan support for 32-bit applications, also add:
|
||||
<xref linkend="opt-hardware.opengl.extraPackages32"/> = [
|
||||
pkgs.driversi686Linux.<package>amdvlk</package>
|
||||
];
|
||||
# To enable Vulkan support for 32-bit applications, also add:
|
||||
<xref linkend="opt-hardware.opengl.extraPackages32"/> = [
|
||||
pkgs.driversi686Linux.<package>amdvlk</package>
|
||||
];
|
||||
|
||||
# For amdvlk
|
||||
<xref linkend="opt-environment.variables"/>.VK_ICD_FILENAMES =
|
||||
"/run/opengl-driver/share/vulkan/icd.d/amd_icd64.json";
|
||||
# For radv
|
||||
<xref linkend="opt-environment.variables"/>.VK_ICD_FILENAMES =
|
||||
"/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json";
|
||||
</programlisting>
|
||||
# For amdvlk
|
||||
<xref linkend="opt-environment.variables"/>.VK_ICD_FILENAMES =
|
||||
"/run/opengl-driver/share/vulkan/icd.d/amd_icd64.json";
|
||||
# For radv
|
||||
<xref linkend="opt-environment.variables"/>.VK_ICD_FILENAMES =
|
||||
"/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json";
|
||||
</programlisting>
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
<chapter xmlns="http://docbook.org/ns/docbook"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
version="5.0"
|
||||
xml:id="module-services-subversion">
|
||||
<title>Subversion</title>
|
||||
|
||||
<para>
|
||||
<link xlink:href="https://subversion.apache.org/">Subversion</link>
|
||||
is a centralized version-control system. It can use a <link
|
||||
xlink:href="http://svnbook.red-bean.com/en/1.7/svn-book.html#svn.serverconfig.choosing">variety
|
||||
of protocols</link> for communication between client and server.
|
||||
</para>
|
||||
<section xml:id="module-services-subversion-apache-httpd">
|
||||
<title>Subversion inside Apache HTTP</title>
|
||||
|
||||
<para>
|
||||
This section focuses on configuring a web-based server on top of
|
||||
the Apache HTTP server, which uses
|
||||
<link xlink:href="http://www.webdav.org/">WebDAV</link>/<link
|
||||
xlink:href="http://www.webdav.org/deltav/WWW10/deltav-intro.htm">DeltaV</link>
|
||||
for communication.
|
||||
</para>
|
||||
|
||||
<para>For more information on the general setup, please refer to
|
||||
the <link
|
||||
xlink:href="http://svnbook.red-bean.com/en/1.7/svn-book.html#svn.serverconfig.httpd">the
|
||||
appropriate section of the Subversion book</link>.
|
||||
</para>
|
||||
|
||||
<para>To configure, include in
|
||||
<literal>/etc/nixos/configuration.nix</literal> code to activate
|
||||
Apache HTTP, setting <xref linkend="opt-services.httpd.adminAddr" />
|
||||
appropriately:
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<programlisting>
|
||||
services.httpd.enable = true;
|
||||
services.httpd.adminAddr = ...;
|
||||
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
<para>For a simple Subversion server with basic authentication,
|
||||
configure the Subversion module for Apache as follows, setting
|
||||
<literal>hostName</literal> and <literal>documentRoot</literal>
|
||||
appropriately, and <literal>SVNParentPath</literal> to the parent
|
||||
directory of the repositories,
|
||||
<literal>AuthzSVNAccessFile</literal> to the location of the
|
||||
<code>.authz</code> file describing access permission, and
|
||||
<literal>AuthUserFile</literal> to the password file.
|
||||
</para>
|
||||
<para>
|
||||
<programlisting>
|
||||
services.httpd.extraModules = [
|
||||
# note that order is *super* important here
|
||||
{ name = "dav_svn"; path = "${pkgs.apacheHttpdPackages.subversion}/modules/mod_dav_svn.so"; }
|
||||
{ name = "authz_svn"; path = "${pkgs.apacheHttpdPackages.subversion}/modules/mod_authz_svn.so"; }
|
||||
];
|
||||
services.httpd.virtualHosts = {
|
||||
"svn" = {
|
||||
hostName = HOSTNAME;
|
||||
documentRoot = DOCUMENTROOT;
|
||||
locations."/svn".extraConfig = ''
|
||||
DAV svn
|
||||
SVNParentPath REPO_PARENT
|
||||
AuthzSVNAccessFile ACCESS_FILE
|
||||
AuthName "SVN Repositories"
|
||||
AuthType Basic
|
||||
AuthUserFile PASSWORD_FILE
|
||||
Require valid-user
|
||||
'';
|
||||
}
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The key <code>"svn"</code> is just a symbolic name identifying the
|
||||
virtual host. The <code>"/svn"</code> in
|
||||
<code>locations."/svn".extraConfig</code> is the path underneath
|
||||
which the repositories will be served.
|
||||
</para>
|
||||
|
||||
<para><link
|
||||
xlink:href="https://wiki.archlinux.org/index.php/Subversion">This
|
||||
page</link> explains how to set up the Subversion configuration
|
||||
itself. This boils down to the following:
|
||||
</para>
|
||||
<para>
|
||||
Underneath <literal>REPO_PARENT</literal> repositories can be set up
|
||||
as follows:
|
||||
</para>
|
||||
<para>
|
||||
<screen>
|
||||
<prompt>$ </prompt> svn create REPO_NAME
|
||||
</screen>
|
||||
</para>
|
||||
<para>Repository files need to be accessible by
|
||||
<literal>wwwrun</literal>:
|
||||
</para>
|
||||
<para>
|
||||
<screen>
|
||||
<prompt>$ </prompt> chown -R wwwrun:wwwrun REPO_PARENT
|
||||
</screen>
|
||||
</para>
|
||||
<para>
|
||||
The password file <literal>PASSWORD_FILE</literal> can be created as follows:
|
||||
</para>
|
||||
<para>
|
||||
<screen>
|
||||
<prompt>$ </prompt> htpasswd -cs PASSWORD_FILE USER_NAME
|
||||
</screen>
|
||||
</para>
|
||||
<para>
|
||||
Additional users can be set up similarly, omitting the
|
||||
<code>c</code> flag:
|
||||
</para>
|
||||
<para>
|
||||
<screen>
|
||||
<prompt>$ </prompt> htpasswd -s PASSWORD_FILE USER_NAME
|
||||
</screen>
|
||||
</para>
|
||||
<para>
|
||||
The file describing access permissions
|
||||
<literal>ACCESS_FILE</literal> will look something like
|
||||
the following:
|
||||
</para>
|
||||
<para>
|
||||
<programlisting>
|
||||
[/]
|
||||
* = r
|
||||
|
||||
[REPO_NAME:/]
|
||||
USER_NAME = rw
|
||||
</programlisting>
|
||||
</para>
|
||||
<para>The Subversion repositories will be accessible as <code>http://HOSTNAME/svn/REPO_NAME</code>.</para>
|
||||
</section>
|
||||
</chapter>
|
|
@ -0,0 +1,23 @@
|
|||
<chapter xmlns="http://docbook.org/ns/docbook"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
version="5.0"
|
||||
xml:id="sec-wayland">
|
||||
<title>Wayland</title>
|
||||
|
||||
<para>
|
||||
While X11 (see <xref linkend="sec-x11"/>) is still the primary display
|
||||
technology on NixOS, Wayland support is steadily improving.
|
||||
Where X11 separates the X Server and the window manager, on Wayland those
|
||||
are combined: a Wayland Compositor is like an X11 window manager, but also
|
||||
embeds the Wayland 'Server' functionality. This means it is sufficient to
|
||||
install a Wayland Compositor such as <package>sway</package> without
|
||||
separately enabling a Wayland server:
|
||||
<programlisting>
|
||||
<xref linkend="opt-programs.sway.enable"/> = true;
|
||||
</programlisting>
|
||||
This installs the <package>sway</package> compositor along with some
|
||||
essential utilities. Now you can start <package>sway</package> from the TTY
|
||||
console.
|
||||
</para>
|
||||
</chapter>
|
|
@ -12,7 +12,7 @@ xlink:href="https://github.com/NixOS/nixpkgs">Nixpkgs</link> repository.
|
|||
You can quickly check your edits with the following:
|
||||
</para>
|
||||
<screen>
|
||||
<prompt>$ </prompt>cd /path/to/nixpkgs/nixos/doc/manual
|
||||
<prompt>$ </prompt>cd /path/to/nixpkgs
|
||||
<prompt>$ </prompt>nix-build nixos/release.nix -A manual.x86_64-linux
|
||||
</screen>
|
||||
<para>
|
||||
|
|
|
@ -63,6 +63,7 @@ let
|
|||
"--stringparam html.script './highlightjs/highlight.pack.js ./highlightjs/loader.js'"
|
||||
"--param xref.with.number.and.title 1"
|
||||
"--param toc.section.depth 0"
|
||||
"--param generate.consistent.ids 1"
|
||||
"--stringparam admon.style ''"
|
||||
"--stringparam callout.graphics.extension .svg"
|
||||
"--stringparam current.docid manual"
|
||||
|
|
|
@ -161,6 +161,13 @@ nixpkgs https://nixos.org/channels/nixpkgs-unstable</screen>
|
|||
existing systems without the help of a rescue USB drive or similar.
|
||||
</para>
|
||||
</warning>
|
||||
<note>
|
||||
<para>
|
||||
On some distributions there are separate PATHS for programs intended only for root.
|
||||
In order for the installation to succeed, you might have to use <literal>PATH="$PATH:/usr/sbin:/sbin"</literal>
|
||||
in the following command.
|
||||
</para>
|
||||
</note>
|
||||
<screen><prompt>$ </prompt>sudo PATH="$PATH" NIX_PATH="$NIX_PATH" `which nixos-install` --root /mnt</screen>
|
||||
<para>
|
||||
Again, please refer to the <literal>nixos-install</literal> step in
|
||||
|
|
|
@ -49,6 +49,12 @@
|
|||
<option>--flake</option> <replaceable>flake-uri</replaceable>
|
||||
</arg>
|
||||
|
||||
<arg>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'><option>--impure</option></arg>
|
||||
</group>
|
||||
</arg>
|
||||
|
||||
<arg>
|
||||
<arg choice='plain'>
|
||||
<option>--channel</option>
|
||||
|
@ -100,6 +106,12 @@
|
|||
</arg>
|
||||
</arg>
|
||||
|
||||
<arg>
|
||||
<arg choice='plain'>
|
||||
<option>--keep-going</option>
|
||||
</arg>
|
||||
</arg>
|
||||
|
||||
<arg>
|
||||
<arg choice='plain'>
|
||||
<option>--help</option>
|
||||
|
@ -295,6 +307,17 @@
|
|||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--keep-going</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Causes Nix to continue building derivations as far as possible
|
||||
in the face of failed builds.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--help</option>
|
||||
|
|
|
@ -234,7 +234,17 @@
|
|||
</listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Starting with this release, the hydra-build-result
|
||||
<literal>nixos-<replaceable>YY.MM</replaceable></literal>
|
||||
branches no longer exist in the <link
|
||||
xlink:href="https://github.com/nixos/nixpkgs-channels">deprecated
|
||||
nixpkgs-channels repository</link>. These branches are now in
|
||||
<link xlink:href="https://github.com/nixos/nixpkgs">the main nixpkgs
|
||||
repository</link>.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
|
@ -879,12 +889,23 @@ php.override {
|
|||
<listitem>
|
||||
<para>
|
||||
Nginx web server now starting with additional sandbox/hardening options. By default, write access
|
||||
to <literal>services.nginx.stateDir</literal> is allowed. To allow writing to other folders,
|
||||
to <literal>/var/log/nginx</literal> and <literal>/var/cache/nginx</literal> is allowed. To allow writing to other folders,
|
||||
use <literal>systemd.services.nginx.serviceConfig.ReadWritePaths</literal>
|
||||
<programlisting>
|
||||
systemd.services.nginx.serviceConfig.ReadWritePaths = [ "/var/www" ];
|
||||
</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
Nginx is also started with the systemd option <literal>ProtectHome = mkDefault true;</literal>
|
||||
which forbids it to read anything from <literal>/home</literal>, <literal>/root</literal>
|
||||
and <literal>/run/user</literal> (see
|
||||
<link xlink:href="https://www.freedesktop.org/software/systemd/man/systemd.exec.html#ProtectHome=">ProtectHome docs</link>
|
||||
for details).
|
||||
If you require serving files from home directories, you may choose to set e.g.
|
||||
<programlisting>
|
||||
systemd.services.nginx.serviceConfig.ProtectHome = "read-only";
|
||||
</programlisting>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
|
@ -1582,30 +1603,30 @@ services.transmission.settings.rpc-bind-address = "0.0.0.0";
|
|||
<para>
|
||||
Agda has been heavily reworked.
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>agda.mkDerivation</literal> has been heavily changed and
|
||||
is now located at <package>agdaPackages.mkDerivation</package>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
New top-level packages <package>agda</package> and
|
||||
<literal>agda.withPackages</literal> have been added, the second
|
||||
of which sets up agda with access to chosen libraries.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
All agda libraries now live under
|
||||
<literal>agdaPackages</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Many broken libraries have been removed.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>agda.mkDerivation</literal> has been heavily changed and
|
||||
is now located at <package>agdaPackages.mkDerivation</package>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
New top-level packages <package>agda</package> and
|
||||
<literal>agda.withPackages</literal> have been added, the second
|
||||
of which sets up agda with access to chosen libraries.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
All agda libraries now live under
|
||||
<literal>agdaPackages</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Many broken libraries have been removed.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
See the <link
|
||||
xlink:href="https://nixos.org/nixpkgs/manual/#agda">new
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
Support is planned until the end of October 2021, handing over to 21.09.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>GNOME desktop environment was upgraded to 3.38, see its <link xlink:href="https://help.gnome.org/misc/release-notes/3.38/">release notes</link>.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
|
@ -39,7 +42,24 @@
|
|||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para />
|
||||
<para>
|
||||
<link xlink:href="https://www.keycloak.org/">Keycloak</link>,
|
||||
an open source identity and access management server with
|
||||
support for <link
|
||||
xlink:href="https://openid.net/connect/">OpenID Connect</link>,
|
||||
<link xlink:href="https://oauth.net/2/">OAUTH 2.0</link> and
|
||||
<link xlink:href="https://en.wikipedia.org/wiki/SAML_2.0">SAML
|
||||
2.0</link>.
|
||||
</para>
|
||||
<para>
|
||||
See the <link linkend="module-services-keycloak">Keycloak
|
||||
section of the NixOS manual</link> for more information.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<xref linkend="opt-services.samba-wsdd.enable" /> Web Services Dynamic Discovery host daemon
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
|
@ -74,6 +94,25 @@
|
|||
user D-Bus session available also for non-graphical logins.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>rubyMinimal</literal> was removed due to being unused and
|
||||
unusable. The default ruby interpreter includes JIT support, which makes
|
||||
it reference it's compiler. Since JIT support is probably needed by some
|
||||
Gems, it was decided to enable this feature with all cc references by
|
||||
default, and allow to build a Ruby derivation without references to cc,
|
||||
by setting <literal>jitSupport = false;</literal> in an overlay. See
|
||||
<link xlink:href="https://github.com/NixOS/nixpkgs/pull/90151">#90151</link>
|
||||
for more info.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Setting <option>services.openssh.authorizedKeysFiles</option> now also affects which keys <option>security.pam.enableSSHAgentAuth</option> will use.
|
||||
|
||||
WARNING: If you are using these options in combination do make sure that any key paths you use are present in <option>services.openssh.authorizedKeysFiles</option>!
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
The option <option>fonts.enableFontDir</option> has been renamed to
|
||||
|
@ -99,6 +138,13 @@
|
|||
to <literal>/run/pdns-recursor</literal> to match upstream.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Paperwork was updated to version 2. The on-disk format slightly changed,
|
||||
and it is not possible to downgrade from Paperwork 2 back to Paperwork
|
||||
1.3. Back your documents up before upgrading. See <link xlink:href="https://forum.openpaper.work/t/paperwork-2-0/112/5">this thread</link> for more details.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
PowerDNS has been updated from <literal>4.2.x</literal> to <literal>4.3.x</literal>. Please
|
||||
|
@ -109,6 +155,90 @@
|
|||
<literal>/var/lib/powerdns</literal> to <literal>/run/pdns</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<package>btc1</package> has been abandoned upstream, and removed.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<package>riak-cs</package> package removed along with <varname>services.riak-cs</varname> module.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<package>stanchion</package> package removed along with <varname>services.stanchion</varname> module.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<package>mutt</package> has been updated to a new major version (2.x), which comes with
|
||||
some backward incompatible changes that are described in the
|
||||
<link xlink:href="http://www.mutt.org/relnotes/2.0/">release notes for Mutt 2.0</link>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>vim</literal> switched to Python 3, dropping all Python 2 support.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="opt-boot.zfs.forceImportAll">boot.zfs.forceImportAll</link>
|
||||
previously did nothing, but has been fixed. However its default has been
|
||||
changed to <literal>false</literal> to preserve the existing default
|
||||
behaviour. If you have this explicitly set to <literal>true</literal>,
|
||||
please note that your non-root pools will now be forcibly imported.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<package>openafs</package> now points to <package>openafs_1_8</package>,
|
||||
which is the new stable release. OpenAFS 1.6 was removed.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
The <literal>openldap</literal> module now has support for OLC-style
|
||||
configuration, users of the <literal>configDir</literal> option may wish
|
||||
to migrate. If you continue to use <literal>configDir</literal>, ensure that
|
||||
<literal>olcPidFile</literal> is set to <literal>/run/slapd/slapd.pid</literal>.
|
||||
</para>
|
||||
<para>
|
||||
As a result, <literal>extraConfig</literal> and <literal>extraDatabaseConfig</literal>
|
||||
are removed. To help with migration, you can convert your <literal>slapd.conf</literal>
|
||||
file to OLC configuration with the following script (find the location of this
|
||||
configuration file by running <literal>systemctl status openldap</literal>, it is the
|
||||
<literal>-f</literal> option.
|
||||
</para>
|
||||
<programlisting>
|
||||
TMPDIR=$(mktemp -d)
|
||||
slaptest -f /path/to/slapd.conf $TMPDIR
|
||||
slapcat -F $TMPDIR -n0 -H 'ldap:///???(!(objectClass=olcSchemaConfig))'
|
||||
</programlisting>
|
||||
<para>
|
||||
This will dump your current configuration in LDIF format, which should be
|
||||
straightforward to convert into Nix settings. This does not show your schema
|
||||
configuration, as this is unnecessarily verbose for users of the default schemas
|
||||
and <literal>slaptest</literal> is buggy with schemas directly in the config file.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Amazon EC2 and OpenStack Compute (nova) images now re-fetch instance meta data and user data from the instance
|
||||
metadata service (IMDS) on each boot. For example: stopping an EC2 instance, changing its user data, and
|
||||
restarting the instance will now cause it to fetch and apply the new user data.
|
||||
</para>
|
||||
<warning>
|
||||
<para>
|
||||
Specifically, <literal>/etc/ec2-metadata</literal> is re-populated on each boot. Some NixOS scripts that read
|
||||
from this directory are guarded to only run if the files they want to manipulate do not already exist, and so
|
||||
will not re-apply their changes if the IMDS response changes. Examples: <literal>root</literal>'s SSH key is
|
||||
only added if <literal>/root/.ssh/authorized_keys</literal> does not exist, and SSH host keys are only set from
|
||||
user data if they do not exist in <literal>/etc/ssh</literal>.
|
||||
</para>
|
||||
</warning>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
|
@ -132,6 +262,75 @@
|
|||
to <package>nextcloud20</package>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
The setting <xref linkend="opt-services.redis.bind" /> defaults to <literal>127.0.0.1</literal> now, making Redis listen on the loopback interface only, and not all public network interfaces.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
NixOS now emits a deprecation warning if systemd's <literal>StartLimitInterval</literal> setting is used in a <literal>serviceConfig</literal> section instead of in a <literal>unitConfig</literal>; that setting is deprecated and now undocumented for the service section by systemd upstream, but still effective and somewhat buggy there, which can be confusing. See <link xlink:href="https://github.com/NixOS/nixpkgs/issues/45785">#45785</link> for details.
|
||||
</para>
|
||||
<para>
|
||||
All services should use <xref linkend="opt-systemd.services._name_.startLimitIntervalSec" /> or <literal>StartLimitIntervalSec</literal> in <xref linkend="opt-systemd.services._name_.unitConfig" /> instead.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
The Unbound DNS resolver service (<literal>services.unbound</literal>) has been refactored to allow reloading, control sockets and to fix startup ordering issues.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
It is now possible to enable a local UNIX control socket for unbound by setting the <xref linkend="opt-services.unbound.localControlSocketPath" />
|
||||
option.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Previously we just applied a very minimal set of restrictions and
|
||||
trusted unbound to properly drop root privs and capabilities.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
As of this we are (for the most part) just using the upstream
|
||||
example unit file for unbound. The main difference is that we start
|
||||
unbound as <literal>unbound</literal> user with the required capabilities instead of
|
||||
letting unbound do the chroot & uid/gid changes.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The upstream unit configuration this is based on is a lot stricter with
|
||||
all kinds of permissions then our previous variant. It also came with
|
||||
the default of having the <literal>Type</literal> set to <literal>notify</literal>, therefore we are now also
|
||||
using the <literal>unbound-with-systemd</literal> package here. Unbound will start up,
|
||||
read the configuration files and start listening on the configured ports
|
||||
before systemd will declare the unit <literal>active (running)</literal>.
|
||||
This will likely help with startup order and the occasional race condition during system
|
||||
activation where the DNS service is started but not yet ready to answer
|
||||
queries. Services depending on <literal>nss-lookup.target</literal> or <literal>unbound.service</literal>
|
||||
are now be able to use unbound when those targets have been reached.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Aditionally to the much stricter runtime environmet the
|
||||
<literal>/dev/urandom</literal> mount lines we previously had in the code (that would
|
||||
randomly failed during the stop-phase) have been removed as systemd will take care of those for us.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The <literal>preStart</literal> script is now only required if we enabled the trust
|
||||
anchor updates (which are still enabled by default).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Another benefit of the refactoring is that we can now issue reloads via
|
||||
either <literal>pkill -HUP unbound</literal> and <literal>systemctl reload unbound</literal> to reload the
|
||||
running configuration without taking the daemon offline. A prerequisite
|
||||
of this was that unbound configuration is available on a well known path
|
||||
on the file system. We are using the path <literal>/etc/unbound/unbound.conf</literal> as that is the
|
||||
default in the CLI tooling which in turn enables us to use
|
||||
<literal>unbound-control</literal> without passing a custom configuration location.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
</section>
|
||||
|
|
|
@ -15,8 +15,8 @@ require "rexml/document"
|
|||
include REXML
|
||||
|
||||
if ARGV.length < 1 then
|
||||
$stderr.puts "Needs a filename."
|
||||
exit 1
|
||||
$stderr.puts "Needs a filename."
|
||||
exit 1
|
||||
end
|
||||
|
||||
filename = ARGV.shift
|
||||
|
@ -51,17 +51,17 @@ $touched = false
|
|||
# Generates: --optionnamevalue
|
||||
# ^^ ^^
|
||||
doc.elements.each("//varlistentry/term") do |term|
|
||||
["varname", "function", "option", "replaceable"].each do |prev_name|
|
||||
term.elements.each(prev_name) do |el|
|
||||
if el.next_element and
|
||||
el.next_element.name == "replaceable" and
|
||||
el.next_sibling_node.class == Element
|
||||
then
|
||||
$touched = true
|
||||
term.insert_after(el, Text.new(" "))
|
||||
end
|
||||
end
|
||||
end
|
||||
["varname", "function", "option", "replaceable"].each do |prev_name|
|
||||
term.elements.each(prev_name) do |el|
|
||||
if el.next_element and
|
||||
el.next_element.name == "replaceable" and
|
||||
el.next_sibling_node.class == Element
|
||||
then
|
||||
$touched = true
|
||||
term.insert_after(el, Text.new(" "))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
@ -75,17 +75,17 @@ end
|
|||
# Generates: -Ipath
|
||||
# ^^
|
||||
doc.elements.each("//cmdsynopsis/arg") do |term|
|
||||
["option", "replaceable"].each do |prev_name|
|
||||
term.elements.each(prev_name) do |el|
|
||||
if el.next_element and
|
||||
el.next_element.name == "replaceable" and
|
||||
el.next_sibling_node.class == Element
|
||||
then
|
||||
$touched = true
|
||||
term.insert_after(el, Text.new(" "))
|
||||
end
|
||||
end
|
||||
end
|
||||
["option", "replaceable"].each do |prev_name|
|
||||
term.elements.each(prev_name) do |el|
|
||||
if el.next_element and
|
||||
el.next_element.name == "replaceable" and
|
||||
el.next_sibling_node.class == Element
|
||||
then
|
||||
$touched = true
|
||||
term.insert_after(el, Text.new(" "))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# <cmdsynopsis>
|
||||
|
@ -104,21 +104,21 @@ end
|
|||
# Generates: [{--profile-name | -p }name]
|
||||
# ^^^^
|
||||
doc.elements.each("//cmdsynopsis/arg") do |term|
|
||||
["group"].each do |prev_name|
|
||||
term.elements.each(prev_name) do |el|
|
||||
if el.next_element and
|
||||
el.next_element.name == "replaceable" and
|
||||
el.next_sibling_node.class == Element
|
||||
then
|
||||
$touched = true
|
||||
term.insert_after(el, Text.new(" "))
|
||||
end
|
||||
end
|
||||
end
|
||||
["group"].each do |prev_name|
|
||||
term.elements.each(prev_name) do |el|
|
||||
if el.next_element and
|
||||
el.next_element.name == "replaceable" and
|
||||
el.next_sibling_node.class == Element
|
||||
then
|
||||
$touched = true
|
||||
term.insert_after(el, Text.new(" "))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if $touched then
|
||||
doc.context[:attribute_quote] = :quote
|
||||
doc.write(output: File.open(filename, "w"))
|
||||
doc.context[:attribute_quote] = :quote
|
||||
doc.write(output: File.open(filename, "w"))
|
||||
end
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
# partition of reasonable size is created in addition to the root partition.
|
||||
# For "legacy", the msdos partition table is used and a single large root
|
||||
# partition is created.
|
||||
# For "legacy+gpt", the GPT partition table is used, a 1MiB no-fs partition for
|
||||
# use by the bootloader is created, and a single large root partition is
|
||||
# created.
|
||||
# For "hybrid", the GPT partition table is used and a mandatory ESP
|
||||
# partition of reasonable size is created in addition to the root partition.
|
||||
# Also a legacy MBR will be present.
|
||||
|
@ -54,7 +57,7 @@
|
|||
format ? "raw"
|
||||
}:
|
||||
|
||||
assert partitionTableType == "legacy" || partitionTableType == "efi" || partitionTableType == "hybrid" || partitionTableType == "none";
|
||||
assert partitionTableType == "legacy" || partitionTableType == "legacy+gpt" || partitionTableType == "efi" || partitionTableType == "hybrid" || partitionTableType == "none";
|
||||
# We use -E offset=X below, which is only supported by e2fsprogs
|
||||
assert partitionTableType != "none" -> fsType == "ext4";
|
||||
|
||||
|
@ -75,6 +78,7 @@ let format' = format; in let
|
|||
|
||||
rootPartition = { # switch-case
|
||||
legacy = "1";
|
||||
"legacy+gpt" = "2";
|
||||
efi = "2";
|
||||
hybrid = "3";
|
||||
}.${partitionTableType};
|
||||
|
@ -85,6 +89,16 @@ let format' = format; in let
|
|||
mklabel msdos \
|
||||
mkpart primary ext4 1MiB -1
|
||||
'';
|
||||
"legacy+gpt" = ''
|
||||
parted --script $diskImage -- \
|
||||
mklabel gpt \
|
||||
mkpart no-fs 1MB 2MB \
|
||||
set 1 bios_grub on \
|
||||
align-check optimal 1 \
|
||||
mkpart primary ext4 2MB -1 \
|
||||
align-check optimal 2 \
|
||||
print
|
||||
'';
|
||||
efi = ''
|
||||
parted --script $diskImage -- \
|
||||
mklabel gpt \
|
||||
|
@ -120,7 +134,7 @@ let format' = format; in let
|
|||
|
||||
binPath = with pkgs; makeBinPath (
|
||||
[ rsync
|
||||
utillinux
|
||||
util-linux
|
||||
parted
|
||||
e2fsprogs
|
||||
lkl
|
||||
|
@ -225,7 +239,7 @@ let format' = format; in let
|
|||
in pkgs.vmTools.runInLinuxVM (
|
||||
pkgs.runCommand name
|
||||
{ preVM = prepareImage;
|
||||
buildInputs = with pkgs; [ utillinux e2fsprogs dosfstools ];
|
||||
buildInputs = with pkgs; [ util-linux e2fsprogs dosfstools ];
|
||||
postVM = ''
|
||||
${if format == "raw" then ''
|
||||
mv $diskImage $out/${filename}
|
||||
|
|
|
@ -48,7 +48,7 @@ assert usbBootable -> isohybridMbrImage != "";
|
|||
stdenv.mkDerivation {
|
||||
name = isoName;
|
||||
builder = ./make-iso9660-image.sh;
|
||||
buildInputs = [ xorriso syslinux zstd libossp_uuid ];
|
||||
nativeBuildInputs = [ xorriso syslinux zstd libossp_uuid ];
|
||||
|
||||
inherit isoName bootable bootImage compressImage volumeID efiBootImage efiBootable isohybridMbrImage usbBootable;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ in
|
|||
stdenv.mkDerivation {
|
||||
name = "tarball";
|
||||
builder = ./make-system-tarball.sh;
|
||||
buildInputs = extraInputs;
|
||||
nativeBuildInputs = extraInputs;
|
||||
|
||||
inherit fileName extraArgs extraCommands compressCommand;
|
||||
|
||||
|
|
|
@ -634,8 +634,7 @@ class Machine:
|
|||
shutil.copy(intermediate, abs_target)
|
||||
|
||||
def dump_tty_contents(self, tty: str) -> None:
|
||||
"""Debugging: Dump the contents of the TTY<n>
|
||||
"""
|
||||
"""Debugging: Dump the contents of the TTY<n>"""
|
||||
self.execute("fold -w 80 /dev/vcs{} | systemd-cat".format(tty))
|
||||
|
||||
def get_screen_text(self) -> str:
|
||||
|
@ -860,8 +859,7 @@ class Machine:
|
|||
self.send_monitor_command("set_link virtio-net-pci.1 off")
|
||||
|
||||
def unblock(self) -> None:
|
||||
"""Make the machine reachable.
|
||||
"""
|
||||
"""Make the machine reachable."""
|
||||
self.send_monitor_command("set_link virtio-net-pci.1 on")
|
||||
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ in {
|
|||
inherit (cfg) contents format name;
|
||||
pkgs = import ../../../.. { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package
|
||||
partitionTableType = if config.ec2.efi then "efi"
|
||||
else if config.ec2.hvm then "legacy"
|
||||
else if config.ec2.hvm then "legacy+gpt"
|
||||
else "none";
|
||||
diskSize = cfg.sizeMB;
|
||||
fsType = "ext4";
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -p awscli -p jq -p qemu -i bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
# Uploads and registers NixOS images built from the
|
||||
# <nixos/release.nix> amazonImage attribute. Images are uploaded and
|
||||
# registered via a home region, and then copied to other regions.
|
||||
|
||||
# The home region requires an s3 bucket, and a "vmimport" IAM role
|
||||
# with access to the S3 bucket. Configuration of the vmimport role is
|
||||
# documented in
|
||||
# The home region requires an s3 bucket, and an IAM role named "vmimport"
|
||||
# (by default) with access to the S3 bucket. The name can be
|
||||
# configured with the "service_role_name" variable. Configuration of the
|
||||
# vmimport role is documented in
|
||||
# https://docs.aws.amazon.com/vm-import/latest/userguide/vmimport-image-import.html
|
||||
|
||||
# set -x
|
||||
|
@ -17,6 +19,7 @@ set -euo pipefail
|
|||
state_dir=$HOME/amis/ec2-images
|
||||
home_region=eu-west-1
|
||||
bucket=nixos-amis
|
||||
service_role_name=vmimport
|
||||
|
||||
regions=(eu-west-1 eu-west-2 eu-west-3 eu-central-1 eu-north-1
|
||||
us-east-1 us-east-2 us-west-1 us-west-2
|
||||
|
@ -64,7 +67,7 @@ image_logical_bytes=$(read_image_info .logical_bytes)
|
|||
|
||||
# Derived attributes
|
||||
|
||||
image_logical_gigabytes=$((($image_logical_bytes-1)/1024/1024/1024+1)) # Round to the next GB
|
||||
image_logical_gigabytes=$(((image_logical_bytes-1)/1024/1024/1024+1)) # Round to the next GB
|
||||
|
||||
case "$image_system" in
|
||||
aarch64-linux)
|
||||
|
@ -100,7 +103,7 @@ write_state() {
|
|||
local type=$2
|
||||
local val=$3
|
||||
|
||||
mkdir -p $state_dir
|
||||
mkdir -p "$state_dir"
|
||||
echo "$val" > "$state_dir/$state_key.$type"
|
||||
}
|
||||
|
||||
|
@ -110,8 +113,8 @@ wait_for_import() {
|
|||
local state snapshot_id
|
||||
log "Waiting for import task $task_id to be completed"
|
||||
while true; do
|
||||
read state progress snapshot_id < <(
|
||||
aws ec2 describe-import-snapshot-tasks --region $region --import-task-ids "$task_id" | \
|
||||
read -r state progress snapshot_id < <(
|
||||
aws ec2 describe-import-snapshot-tasks --region "$region" --import-task-ids "$task_id" | \
|
||||
jq -r '.ImportSnapshotTasks[].SnapshotTaskDetail | "\(.Status) \(.Progress) \(.SnapshotId)"'
|
||||
)
|
||||
log " ... state=$state progress=$progress snapshot_id=$snapshot_id"
|
||||
|
@ -125,6 +128,8 @@ wait_for_import() {
|
|||
;;
|
||||
*)
|
||||
log "Unexpected snapshot import state: '${state}'"
|
||||
log "Full response: "
|
||||
aws ec2 describe-import-snapshot-tasks --region "$region" --import-task-ids "$task_id" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
@ -138,8 +143,8 @@ wait_for_image() {
|
|||
log "Waiting for image $ami_id to be available"
|
||||
|
||||
while true; do
|
||||
read state < <(
|
||||
aws ec2 describe-images --image-ids "$ami_id" --region $region | \
|
||||
read -r state < <(
|
||||
aws ec2 describe-images --image-ids "$ami_id" --region "$region" | \
|
||||
jq -r ".Images[].State"
|
||||
)
|
||||
log " ... state=$state"
|
||||
|
@ -163,7 +168,7 @@ make_image_public() {
|
|||
local region=$1
|
||||
local ami_id=$2
|
||||
|
||||
wait_for_image $region "$ami_id"
|
||||
wait_for_image "$region" "$ami_id"
|
||||
|
||||
log "Making image $ami_id public"
|
||||
|
||||
|
@ -177,27 +182,30 @@ upload_image() {
|
|||
local aws_path=${image_file#/}
|
||||
|
||||
local state_key="$region.$image_label.$image_system"
|
||||
local task_id=$(read_state "$state_key" task_id)
|
||||
local snapshot_id=$(read_state "$state_key" snapshot_id)
|
||||
local ami_id=$(read_state "$state_key" ami_id)
|
||||
local task_id
|
||||
task_id=$(read_state "$state_key" task_id)
|
||||
local snapshot_id
|
||||
snapshot_id=$(read_state "$state_key" snapshot_id)
|
||||
local ami_id
|
||||
ami_id=$(read_state "$state_key" ami_id)
|
||||
|
||||
if [ -z "$task_id" ]; then
|
||||
log "Checking for image on S3"
|
||||
if ! aws s3 ls --region "$region" "s3://${bucket}/${aws_path}" >&2; then
|
||||
log "Image missing from aws, uploading"
|
||||
aws s3 cp --region $region "$image_file" "s3://${bucket}/${aws_path}" >&2
|
||||
aws s3 cp --region "$region" "$image_file" "s3://${bucket}/${aws_path}" >&2
|
||||
fi
|
||||
|
||||
log "Importing image from S3 path s3://$bucket/$aws_path"
|
||||
|
||||
task_id=$(aws ec2 import-snapshot --disk-container "{
|
||||
task_id=$(aws ec2 import-snapshot --role-name "$service_role_name" --disk-container "{
|
||||
\"Description\": \"nixos-image-${image_label}-${image_system}\",
|
||||
\"Format\": \"vhd\",
|
||||
\"UserBucket\": {
|
||||
\"S3Bucket\": \"$bucket\",
|
||||
\"S3Key\": \"$aws_path\"
|
||||
}
|
||||
}" --region $region | jq -r '.ImportTaskId')
|
||||
}" --region "$region" | jq -r '.ImportTaskId')
|
||||
|
||||
write_state "$state_key" task_id "$task_id"
|
||||
fi
|
||||
|
@ -221,16 +229,16 @@ upload_image() {
|
|||
--virtualization-type hvm
|
||||
)
|
||||
|
||||
block_device_mappings+=(DeviceName=/dev/sdb,VirtualName=ephemeral0)
|
||||
block_device_mappings+=(DeviceName=/dev/sdc,VirtualName=ephemeral1)
|
||||
block_device_mappings+=(DeviceName=/dev/sdd,VirtualName=ephemeral2)
|
||||
block_device_mappings+=(DeviceName=/dev/sde,VirtualName=ephemeral3)
|
||||
block_device_mappings+=("DeviceName=/dev/sdb,VirtualName=ephemeral0")
|
||||
block_device_mappings+=("DeviceName=/dev/sdc,VirtualName=ephemeral1")
|
||||
block_device_mappings+=("DeviceName=/dev/sdd,VirtualName=ephemeral2")
|
||||
block_device_mappings+=("DeviceName=/dev/sde,VirtualName=ephemeral3")
|
||||
|
||||
ami_id=$(
|
||||
aws ec2 register-image \
|
||||
--name "$image_name" \
|
||||
--description "$image_description" \
|
||||
--region $region \
|
||||
--region "$region" \
|
||||
--architecture $amazon_arch \
|
||||
--block-device-mappings "${block_device_mappings[@]}" \
|
||||
"${extra_flags[@]}" \
|
||||
|
@ -240,7 +248,7 @@ upload_image() {
|
|||
write_state "$state_key" ami_id "$ami_id"
|
||||
fi
|
||||
|
||||
make_image_public $region "$ami_id"
|
||||
make_image_public "$region" "$ami_id"
|
||||
|
||||
echo "$ami_id"
|
||||
}
|
||||
|
@ -268,7 +276,7 @@ copy_to_region() {
|
|||
write_state "$state_key" ami_id "$ami_id"
|
||||
fi
|
||||
|
||||
make_image_public $region "$ami_id"
|
||||
make_image_public "$region" "$ami_id"
|
||||
|
||||
echo "$ami_id"
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ let
|
|||
};
|
||||
|
||||
scudo = {
|
||||
libPath = "${pkgs.llvmPackages.compiler-rt}/lib/linux/libclang_rt.scudo-x86_64.so";
|
||||
libPath = "${pkgs.llvmPackages_latest.compiler-rt}/lib/linux/libclang_rt.scudo-x86_64.so";
|
||||
description = ''
|
||||
A user-mode allocator based on LLVM Sanitizer’s CombinedAllocator,
|
||||
which aims at providing additional mitigations against heap based
|
||||
|
|
|
@ -36,6 +36,8 @@ let
|
|||
${addModuleIf cfg.zeroconf.discovery.enable "module-zeroconf-discover"}
|
||||
${addModuleIf cfg.tcp.enable (concatStringsSep " "
|
||||
([ "module-native-protocol-tcp" ] ++ allAnon ++ ipAnon))}
|
||||
${addModuleIf config.services.jack.jackd.enable "module-jack-sink"}
|
||||
${addModuleIf config.services.jack.jackd.enable "module-jack-source"}
|
||||
${cfg.extraConfig}
|
||||
'';
|
||||
};
|
||||
|
@ -144,7 +146,9 @@ in {
|
|||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.pulseaudio;
|
||||
default = if config.services.jack.jackd.enable
|
||||
then pkgs.pulseaudioFull
|
||||
else pkgs.pulseaudio;
|
||||
defaultText = "pkgs.pulseaudio";
|
||||
example = literalExample "pkgs.pulseaudioFull";
|
||||
description = ''
|
||||
|
@ -259,7 +263,7 @@ in {
|
|||
(drv: drv.override { pulseaudio = overriddenPackage; })
|
||||
cfg.extraModules;
|
||||
modulePaths = builtins.map
|
||||
(drv: "${drv}/lib/pulse-${overriddenPackage.version}/modules")
|
||||
(drv: "${drv}/${overriddenPackage.pulseDir}/modules")
|
||||
# User-provided extra modules take precedence
|
||||
(overriddenModules ++ [ overriddenPackage ]);
|
||||
in lib.concatStringsSep ":" modulePaths;
|
||||
|
@ -284,6 +288,8 @@ in {
|
|||
RestartSec = "500ms";
|
||||
PassEnvironment = "DISPLAY";
|
||||
};
|
||||
} // optionalAttrs config.services.jack.jackd.enable {
|
||||
environment.JACK_PROMISCUOUS_SERVER = "jackaudio";
|
||||
};
|
||||
sockets.pulseaudio = {
|
||||
wantedBy = [ "sockets.target" ];
|
||||
|
|
|
@ -187,7 +187,7 @@ in
|
|||
before = [ "${realDevice'}.swap" ];
|
||||
# If swap is encrypted, depending on rngd resolves a possible entropy starvation during boot
|
||||
after = mkIf (config.security.rngd.enable && sw.randomEncryption.enable) [ "rngd.service" ];
|
||||
path = [ pkgs.utillinux ] ++ optional sw.randomEncryption.enable pkgs.cryptsetup;
|
||||
path = [ pkgs.util-linux ] ++ optional sw.randomEncryption.enable pkgs.cryptsetup;
|
||||
|
||||
script =
|
||||
''
|
||||
|
|
|
@ -37,7 +37,7 @@ let
|
|||
pkgs.procps
|
||||
pkgs.su
|
||||
pkgs.time
|
||||
pkgs.utillinux
|
||||
pkgs.util-linux
|
||||
pkgs.which
|
||||
pkgs.zstd
|
||||
];
|
||||
|
|
|
@ -16,8 +16,7 @@ my $gidMap = -e $gidMapFile ? decode_json(read_file($gidMapFile)) : {};
|
|||
|
||||
sub updateFile {
|
||||
my ($path, $contents, $perms) = @_;
|
||||
write_file("$path.tmp", { binmode => ':utf8', perms => $perms // 0644 }, $contents);
|
||||
rename("$path.tmp", $path) or die;
|
||||
write_file($path, { atomic => 1, binmode => ':utf8', perms => $perms // 0644 }, $contents) or die;
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,7 +97,7 @@ sub parseGroup {
|
|||
return ($f[0], { name => $f[0], password => $f[1], gid => $gid, members => $f[3] });
|
||||
}
|
||||
|
||||
my %groupsCur = -f "/etc/group" ? map { parseGroup } read_file("/etc/group") : ();
|
||||
my %groupsCur = -f "/etc/group" ? map { parseGroup } read_file("/etc/group", { binmode => ":utf8" }) : ();
|
||||
|
||||
# Read the current /etc/passwd.
|
||||
sub parseUser {
|
||||
|
@ -109,20 +108,19 @@ sub parseUser {
|
|||
return ($f[0], { name => $f[0], fakePassword => $f[1], uid => $uid,
|
||||
gid => $f[3], description => $f[4], home => $f[5], shell => $f[6] });
|
||||
}
|
||||
|
||||
my %usersCur = -f "/etc/passwd" ? map { parseUser } read_file("/etc/passwd") : ();
|
||||
my %usersCur = -f "/etc/passwd" ? map { parseUser } read_file("/etc/passwd", { binmode => ":utf8" }) : ();
|
||||
|
||||
# Read the groups that were created declaratively (i.e. not by groups)
|
||||
# in the past. These must be removed if they are no longer in the
|
||||
# current spec.
|
||||
my $declGroupsFile = "/var/lib/nixos/declarative-groups";
|
||||
my %declGroups;
|
||||
$declGroups{$_} = 1 foreach split / /, -e $declGroupsFile ? read_file($declGroupsFile) : "";
|
||||
$declGroups{$_} = 1 foreach split / /, -e $declGroupsFile ? read_file($declGroupsFile, { binmode => ":utf8" }) : "";
|
||||
|
||||
# Idem for the users.
|
||||
my $declUsersFile = "/var/lib/nixos/declarative-users";
|
||||
my %declUsers;
|
||||
$declUsers{$_} = 1 foreach split / /, -e $declUsersFile ? read_file($declUsersFile) : "";
|
||||
$declUsers{$_} = 1 foreach split / /, -e $declUsersFile ? read_file($declUsersFile, { binmode => ":utf8" }) : "";
|
||||
|
||||
|
||||
# Generate a new /etc/group containing the declared groups.
|
||||
|
@ -175,7 +173,7 @@ foreach my $name (keys %groupsCur) {
|
|||
# Rewrite /etc/group. FIXME: acquire lock.
|
||||
my @lines = map { join(":", $_->{name}, $_->{password}, $_->{gid}, $_->{members}) . "\n" }
|
||||
(sort { $a->{gid} <=> $b->{gid} } values(%groupsOut));
|
||||
updateFile($gidMapFile, encode_json($gidMap));
|
||||
updateFile($gidMapFile, to_json($gidMap));
|
||||
updateFile("/etc/group", \@lines);
|
||||
system("nscd --invalidate group");
|
||||
|
||||
|
@ -251,7 +249,7 @@ foreach my $name (keys %usersCur) {
|
|||
# Rewrite /etc/passwd. FIXME: acquire lock.
|
||||
@lines = map { join(":", $_->{name}, $_->{fakePassword}, $_->{uid}, $_->{gid}, $_->{description}, $_->{home}, $_->{shell}) . "\n" }
|
||||
(sort { $a->{uid} <=> $b->{uid} } (values %usersOut));
|
||||
updateFile($uidMapFile, encode_json($uidMap));
|
||||
updateFile($uidMapFile, to_json($uidMap));
|
||||
updateFile("/etc/passwd", \@lines);
|
||||
system("nscd --invalidate passwd");
|
||||
|
||||
|
@ -260,7 +258,7 @@ system("nscd --invalidate passwd");
|
|||
my @shadowNew;
|
||||
my %shadowSeen;
|
||||
|
||||
foreach my $line (-f "/etc/shadow" ? read_file("/etc/shadow") : ()) {
|
||||
foreach my $line (-f "/etc/shadow" ? read_file("/etc/shadow", { binmode => ":utf8" }) : ()) {
|
||||
chomp $line;
|
||||
my ($name, $hashedPassword, @rest) = split(':', $line, -9);
|
||||
my $u = $usersOut{$name};;
|
||||
|
|
|
@ -80,6 +80,15 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
memoryMax = mkOption {
|
||||
default = null;
|
||||
type = with types; nullOr int;
|
||||
description = ''
|
||||
Maximum total amount of memory (in bytes) that can be used by the zram
|
||||
swap devices.
|
||||
'';
|
||||
};
|
||||
|
||||
priority = mkOption {
|
||||
default = 5;
|
||||
type = types.int;
|
||||
|
@ -146,11 +155,16 @@ in
|
|||
|
||||
# Calculate memory to use for zram
|
||||
mem=$(${pkgs.gawk}/bin/awk '/MemTotal: / {
|
||||
print int($2*${toString cfg.memoryPercent}/100.0/${toString devicesCount}*1024)
|
||||
value=int($2*${toString cfg.memoryPercent}/100.0/${toString devicesCount}*1024);
|
||||
${lib.optionalString (cfg.memoryMax != null) ''
|
||||
memory_max=int(${toString cfg.memoryMax}/${toString devicesCount});
|
||||
if (value > memory_max) { value = memory_max }
|
||||
''}
|
||||
print value
|
||||
}' /proc/meminfo)
|
||||
|
||||
${pkgs.utillinux}/sbin/zramctl --size $mem --algorithm ${cfg.algorithm} /dev/${dev}
|
||||
${pkgs.utillinux}/sbin/mkswap /dev/${dev}
|
||||
${pkgs.util-linux}/sbin/zramctl --size $mem --algorithm ${cfg.algorithm} /dev/${dev}
|
||||
${pkgs.util-linux}/sbin/mkswap /dev/${dev}
|
||||
'';
|
||||
restartIfChanged = false;
|
||||
};
|
||||
|
|
|
@ -19,6 +19,7 @@ in
|
|||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = with pkgs; [ acpilight ];
|
||||
services.udev.packages = with pkgs; [ acpilight ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -147,10 +147,10 @@ in
|
|||
sdImage.storePaths = [ config.system.build.toplevel ];
|
||||
|
||||
system.build.sdImage = pkgs.callPackage ({ stdenv, dosfstools, e2fsprogs,
|
||||
mtools, libfaketime, utillinux, zstd }: stdenv.mkDerivation {
|
||||
mtools, libfaketime, util-linux, zstd }: stdenv.mkDerivation {
|
||||
name = config.sdImage.imageName;
|
||||
|
||||
nativeBuildInputs = [ dosfstools e2fsprogs mtools libfaketime utillinux zstd ];
|
||||
nativeBuildInputs = [ dosfstools e2fsprogs mtools libfaketime util-linux zstd ];
|
||||
|
||||
inherit (config.sdImage) compressImage;
|
||||
|
||||
|
@ -221,7 +221,7 @@ in
|
|||
set -euo pipefail
|
||||
set -x
|
||||
# Figure out device names for the boot device and root filesystem.
|
||||
rootPart=$(${pkgs.utillinux}/bin/findmnt -n -o SOURCE /)
|
||||
rootPart=$(${pkgs.util-linux}/bin/findmnt -n -o SOURCE /)
|
||||
bootDevice=$(lsblk -npo PKNAME $rootPart)
|
||||
|
||||
# Resize the root partition and the filesystem to fit the disk
|
||||
|
|
|
@ -96,7 +96,7 @@ in
|
|||
|
||||
boot.initrd.extraUtilsCommands =
|
||||
''
|
||||
copy_bin_and_libs ${pkgs.utillinux}/sbin/hwclock
|
||||
copy_bin_and_libs ${pkgs.util-linux}/sbin/hwclock
|
||||
'';
|
||||
|
||||
boot.initrd.postDeviceCommands =
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
x86_64-linux = "/nix/store/qxayqjmlpqnmwg5yfsjjayw220ls8i2r-nix-2.3.8";
|
||||
i686-linux = "/nix/store/5834psaay75048jp6d07liqh4j0v1swd-nix-2.3.8";
|
||||
aarch64-linux = "/nix/store/pic90a5fxvifz05jzkd0zak21f9mjin6-nix-2.3.8";
|
||||
x86_64-darwin = "/nix/store/cjx3f8z12wlayp5983kli2a52ipi8jz2-nix-2.3.8";
|
||||
x86_64-linux = "/nix/store/fwak7l5jjl0py4wldsqjbv7p7rdzql0b-nix-2.3.9";
|
||||
i686-linux = "/nix/store/jlqrx9zw3vkwcczndaar5ban1j8g519z-nix-2.3.9";
|
||||
aarch64-linux = "/nix/store/kzvpzlm12185hw27l5znrprgvcja54d0-nix-2.3.9";
|
||||
x86_64-darwin = "/nix/store/kanh3awpf370pxfnjfvkh2m343wr3hj0-nix-2.3.9";
|
||||
}
|
||||
|
|
|
@ -183,6 +183,11 @@ sub pciCheck {
|
|||
push @imports, "(modulesPath + \"/hardware/network/broadcom-43xx.nix\")";
|
||||
}
|
||||
|
||||
# In case this is a virtio scsi device, we need to explicitly make this available.
|
||||
if ($vendor eq "0x1af4" && $device eq "0x1004") {
|
||||
push @initrdAvailableKernelModules, "virtio_scsi";
|
||||
}
|
||||
|
||||
# Can't rely on $module here, since the module may not be loaded
|
||||
# due to missing firmware. Ideally we would check modules.pcimap
|
||||
# here.
|
||||
|
|
|
@ -64,7 +64,7 @@ while [ "$#" -gt 0 ]; do
|
|||
--no-bootloader)
|
||||
noBootLoader=1
|
||||
;;
|
||||
--show-trace)
|
||||
--show-trace|--impure|--keep-going)
|
||||
extraBuildFlags+=("$i")
|
||||
;;
|
||||
--help)
|
||||
|
|
|
@ -40,9 +40,9 @@ let
|
|||
in scrubbedEval.options;
|
||||
};
|
||||
|
||||
helpScript = pkgs.writeScriptBin "nixos-help"
|
||||
''
|
||||
#! ${pkgs.runtimeShell} -e
|
||||
|
||||
nixos-help = let
|
||||
helpScript = pkgs.writeShellScriptBin "nixos-help" ''
|
||||
# Finds first executable browser in a colon-separated list.
|
||||
# (see how xdg-open defines BROWSER)
|
||||
browser="$(
|
||||
|
@ -59,14 +59,22 @@ let
|
|||
exec "$browser" ${manual.manualHTMLIndex}
|
||||
'';
|
||||
|
||||
desktopItem = pkgs.makeDesktopItem {
|
||||
name = "nixos-manual";
|
||||
desktopName = "NixOS Manual";
|
||||
genericName = "View NixOS documentation in a web browser";
|
||||
icon = "nix-snowflake";
|
||||
exec = "${helpScript}/bin/nixos-help";
|
||||
categories = "System";
|
||||
};
|
||||
desktopItem = pkgs.makeDesktopItem {
|
||||
name = "nixos-manual";
|
||||
desktopName = "NixOS Manual";
|
||||
genericName = "View NixOS documentation in a web browser";
|
||||
icon = "nix-snowflake";
|
||||
exec = "nixos-help";
|
||||
categories = "System";
|
||||
};
|
||||
|
||||
in pkgs.symlinkJoin {
|
||||
name = "nixos-help";
|
||||
paths = [
|
||||
helpScript
|
||||
desktopItem
|
||||
];
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
|
@ -250,8 +258,8 @@ in
|
|||
|
||||
environment.systemPackages = []
|
||||
++ optional cfg.man.enable manual.manpages
|
||||
++ optionals cfg.doc.enable ([ manual.manualHTML helpScript ]
|
||||
++ optionals config.services.xserver.enable [ desktopItem pkgs.nixos-icons ]);
|
||||
++ optionals cfg.doc.enable ([ manual.manualHTML nixos-help ]
|
||||
++ optionals config.services.xserver.enable [ pkgs.nixos-icons ]);
|
||||
|
||||
services.mingetty.helpLine = mkIf cfg.doc.enable (
|
||||
"\nRun 'nixos-help' for the NixOS manual."
|
||||
|
|
|
@ -135,7 +135,7 @@ in
|
|||
#keys = 96; # unused
|
||||
#haproxy = 97; # dynamically allocated as of 2020-03-11
|
||||
mongodb = 98;
|
||||
openldap = 99;
|
||||
#openldap = 99; # dynamically allocated as of PR#94610
|
||||
#users = 100; # unused
|
||||
cgminer = 101;
|
||||
munin = 102;
|
||||
|
@ -290,8 +290,8 @@ in
|
|||
hound = 259;
|
||||
leaps = 260;
|
||||
ipfs = 261;
|
||||
stanchion = 262;
|
||||
riak-cs = 263;
|
||||
# stanchion = 262; # unused, removed 2020-10-14
|
||||
# riak-cs = 263; # unused, removed 2020-10-14
|
||||
infinoted = 264;
|
||||
sickbeard = 265;
|
||||
headphones = 266;
|
||||
|
@ -451,7 +451,7 @@ in
|
|||
keys = 96;
|
||||
#haproxy = 97; # dynamically allocated as of 2020-03-11
|
||||
#mongodb = 98; # unused
|
||||
openldap = 99;
|
||||
#openldap = 99; # dynamically allocated as of PR#94610
|
||||
munin = 102;
|
||||
#logcheck = 103; # unused
|
||||
#nix-ssh = 104; # unused
|
||||
|
@ -593,8 +593,8 @@ in
|
|||
hound = 259;
|
||||
leaps = 260;
|
||||
ipfs = 261;
|
||||
stanchion = 262;
|
||||
riak-cs = 263;
|
||||
# stanchion = 262; # unused, removed 2020-10-14
|
||||
# riak-cs = 263; # unused, removed 2020-10-14
|
||||
infinoted = 264;
|
||||
sickbeard = 265;
|
||||
headphones = 266;
|
||||
|
|
|
@ -296,8 +296,6 @@
|
|||
./services/databases/postgresql.nix
|
||||
./services/databases/redis.nix
|
||||
./services/databases/riak.nix
|
||||
./services/databases/riak-cs.nix
|
||||
./services/databases/stanchion.nix
|
||||
./services/databases/victoriametrics.nix
|
||||
./services/databases/virtuoso.nix
|
||||
./services/desktops/accountsservice.nix
|
||||
|
@ -394,6 +392,7 @@
|
|||
./services/logging/logcheck.nix
|
||||
./services/logging/logrotate.nix
|
||||
./services/logging/logstash.nix
|
||||
./services/logging/promtail.nix
|
||||
./services/logging/rsyslogd.nix
|
||||
./services/logging/syslog-ng.nix
|
||||
./services/logging/syslogd.nix
|
||||
|
@ -403,7 +402,6 @@
|
|||
./services/mail/dovecot.nix
|
||||
./services/mail/dspam.nix
|
||||
./services/mail/exim.nix
|
||||
./services/mail/freepops.nix
|
||||
./services/mail/mail.nix
|
||||
./services/mail/mailcatcher.nix
|
||||
./services/mail/mailhog.nix
|
||||
|
@ -544,6 +542,7 @@
|
|||
./services/monitoring/kapacitor.nix
|
||||
./services/monitoring/loki.nix
|
||||
./services/monitoring/longview.nix
|
||||
./services/monitoring/mackerel-agent.nix
|
||||
./services/monitoring/monit.nix
|
||||
./services/monitoring/munin.nix
|
||||
./services/monitoring/nagios.nix
|
||||
|
@ -584,6 +583,7 @@
|
|||
./services/network-filesystems/orangefs/client.nix
|
||||
./services/network-filesystems/rsyncd.nix
|
||||
./services/network-filesystems/samba.nix
|
||||
./services/network-filesystems/samba-wsdd.nix
|
||||
./services/network-filesystems/tahoe.nix
|
||||
./services/network-filesystems/diod.nix
|
||||
./services/network-filesystems/u9fs.nix
|
||||
|
@ -682,6 +682,7 @@
|
|||
./services/networking/murmur.nix
|
||||
./services/networking/mxisd.nix
|
||||
./services/networking/namecoind.nix
|
||||
./services/networking/nar-serve.nix
|
||||
./services/networking/nat.nix
|
||||
./services/networking/ndppd.nix
|
||||
./services/networking/networkmanager.nix
|
||||
|
@ -865,6 +866,7 @@
|
|||
./services/web-apps/ihatemoney
|
||||
./services/web-apps/jirafeau.nix
|
||||
./services/web-apps/jitsi-meet.nix
|
||||
./services/web-apps/keycloak.nix
|
||||
./services/web-apps/limesurvey.nix
|
||||
./services/web-apps/mattermost.nix
|
||||
./services/web-apps/mediawiki.nix
|
||||
|
|
|
@ -4,7 +4,7 @@ with lib;
|
|||
|
||||
let cfg = config.programs.bandwhich;
|
||||
in {
|
||||
meta.maintainers = with maintainers; [ filalex77 ];
|
||||
meta.maintainers = with maintainers; [ Br1ght0ne ];
|
||||
|
||||
options = {
|
||||
programs.bandwhich = {
|
||||
|
|
|
@ -142,6 +142,13 @@ in
|
|||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = cfg.useSTARTTLS -> cfg.useTLS;
|
||||
message = "services.ssmtp.useSTARTTLS has no effect without services.ssmtp.useTLS";
|
||||
}
|
||||
];
|
||||
|
||||
services.ssmtp.settings = mkMerge [
|
||||
({
|
||||
MailHub = cfg.hostName;
|
||||
|
|
|
@ -110,7 +110,7 @@ in {
|
|||
"L+ /usr/local/bin/chmod - - - - ${coreutils}/bin/chmod"
|
||||
"L+ /usr/local/bin/cp - - - - ${coreutils}/bin/cp"
|
||||
"L+ /usr/local/bin/sed - - - - ${gnused}/bin/sed"
|
||||
"L+ /usr/local/bin/setsid - - - - ${utillinux}/bin/setsid"
|
||||
"L+ /usr/local/bin/setsid - - - - ${util-linux}/bin/setsid"
|
||||
"L+ /usr/local/bin/xrandr - - - - ${xorg.xrandr}/bin/xrandr"
|
||||
"L+ /usr/local/bin/xmodmap - - - - ${xorg.xmodmap}/bin/xmodmap"
|
||||
];
|
||||
|
|
|
@ -396,7 +396,7 @@ let
|
|||
${optionalString cfg.logFailures
|
||||
"auth required pam_tally.so"}
|
||||
${optionalString (config.security.pam.enableSSHAgentAuth && cfg.sshAgentAuth)
|
||||
"auth sufficient ${pkgs.pam_ssh_agent_auth}/libexec/pam_ssh_agent_auth.so file=~/.ssh/authorized_keys:~/.ssh/authorized_keys2:/etc/ssh/authorized_keys.d/%u"}
|
||||
"auth sufficient ${pkgs.pam_ssh_agent_auth}/libexec/pam_ssh_agent_auth.so file=${lib.concatStringsSep ":" config.services.openssh.authorizedKeysFiles}"}
|
||||
${optionalString cfg.fprintAuth
|
||||
"auth sufficient ${pkgs.fprintd}/lib/security/pam_fprintd.so"}
|
||||
${let p11 = config.security.pam.p11; in optionalString cfg.p11Auth
|
||||
|
|
|
@ -60,7 +60,7 @@ in
|
|||
<!-- if activated, requires ofl from hxtools to be present -->
|
||||
<logout wait="0" hup="no" term="no" kill="no" />
|
||||
<!-- set PATH variable for pam_mount module -->
|
||||
<path>${pkgs.utillinux}/bin</path>
|
||||
<path>${pkgs.util-linux}/bin</path>
|
||||
<!-- create mount point if not present -->
|
||||
<mkmountpoint enable="1" remove="true" />
|
||||
|
||||
|
|
|
@ -163,8 +163,8 @@ in
|
|||
# These are mount related wrappers that require the +s permission.
|
||||
fusermount.source = "${pkgs.fuse}/bin/fusermount";
|
||||
fusermount3.source = "${pkgs.fuse3}/bin/fusermount3";
|
||||
mount.source = "${lib.getBin pkgs.utillinux}/bin/mount";
|
||||
umount.source = "${lib.getBin pkgs.utillinux}/bin/umount";
|
||||
mount.source = "${lib.getBin pkgs.util-linux}/bin/mount";
|
||||
umount.source = "${lib.getBin pkgs.util-linux}/bin/umount";
|
||||
};
|
||||
|
||||
boot.specialFileSystems.${parentWrapperDir} = {
|
||||
|
|
|
@ -45,7 +45,7 @@ in
|
|||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
path = with pkgs; [
|
||||
utillinux # for dmesg
|
||||
util-linux # for dmesg
|
||||
];
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.salt}/bin/salt-master";
|
||||
|
|
|
@ -50,7 +50,7 @@ in
|
|||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
path = with pkgs; [
|
||||
utillinux
|
||||
util-linux
|
||||
];
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.salt}/bin/salt-minion";
|
||||
|
|
|
@ -246,6 +246,9 @@ in {
|
|||
description = "JACK Audio Connection Kit";
|
||||
serviceConfig = {
|
||||
User = "jackaudio";
|
||||
SupplementaryGroups = lib.optional
|
||||
(config.hardware.pulseaudio.enable
|
||||
&& !config.hardware.pulseaudio.systemWide) "users";
|
||||
ExecStart = "${cfg.jackd.package}/bin/jackd ${lib.escapeShellArgs cfg.jackd.extraOptions}";
|
||||
LimitRTPRIO = 99;
|
||||
LimitMEMLOCK = "infinity";
|
||||
|
|
|
@ -308,7 +308,7 @@ in
|
|||
requires = [ "network-online.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
|
||||
path = with pkgs; [ iputils tarsnap utillinux ];
|
||||
path = with pkgs; [ iputils tarsnap util-linux ];
|
||||
|
||||
# In order for the persistent tarsnap timer to work reliably, we have to
|
||||
# make sure that the tarsnap server is reachable after systemd starts up
|
||||
|
@ -355,7 +355,7 @@ in
|
|||
description = "Tarsnap restore '${name}'";
|
||||
requires = [ "network-online.target" ];
|
||||
|
||||
path = with pkgs; [ iputils tarsnap utillinux ];
|
||||
path = with pkgs; [ iputils tarsnap util-linux ];
|
||||
|
||||
script = let
|
||||
tarsnap = ''tarsnap --configfile "/etc/tarsnap/${name}.conf"'';
|
||||
|
|
|
@ -241,7 +241,7 @@ in
|
|||
description = "Kubernetes Kubelet Service";
|
||||
wantedBy = [ "kubernetes.target" ];
|
||||
after = [ "network.target" "docker.service" "kube-apiserver.service" ];
|
||||
path = with pkgs; [ gitMinimal openssh docker utillinux iproute ethtool thin-provisioning-tools iptables socat ] ++ top.path;
|
||||
path = with pkgs; [ gitMinimal openssh docker util-linux iproute ethtool thin-provisioning-tools iptables socat ] ++ top.path;
|
||||
preStart = ''
|
||||
${concatMapStrings (img: ''
|
||||
echo "Seeding docker image: ${img}"
|
||||
|
|
|
@ -32,7 +32,7 @@ in
|
|||
environment.systemPackages = [ pkgs.torque ];
|
||||
|
||||
systemd.services.torque-mom-init = {
|
||||
path = with pkgs; [ torque utillinux procps inetutils ];
|
||||
path = with pkgs; [ torque util-linux procps inetutils ];
|
||||
|
||||
script = ''
|
||||
pbs_mkdirs -v aux
|
||||
|
|
|
@ -21,7 +21,7 @@ in
|
|||
environment.systemPackages = [ pkgs.torque ];
|
||||
|
||||
systemd.services.torque-server-init = {
|
||||
path = with pkgs; [ torque utillinux procps inetutils ];
|
||||
path = with pkgs; [ torque util-linux procps inetutils ];
|
||||
|
||||
script = ''
|
||||
tmpsetup=$(mktemp -t torque-XXXX)
|
||||
|
|
|
@ -541,7 +541,7 @@ in
|
|||
jq
|
||||
moreutils
|
||||
remarshal
|
||||
utillinux
|
||||
util-linux
|
||||
cfg.package
|
||||
] ++ cfg.extraPackages;
|
||||
reloadIfChanged = true;
|
||||
|
|
|
@ -25,19 +25,18 @@ in
|
|||
];
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
systemd.services.hercules-ci-agent = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
path = [ config.nix.package ];
|
||||
startLimitBurst = 30 * 1000000; # practically infinite
|
||||
serviceConfig = {
|
||||
User = "hercules-ci-agent";
|
||||
ExecStart = command;
|
||||
ExecStartPre = testCommand;
|
||||
Restart = "on-failure";
|
||||
RestartSec = 120;
|
||||
StartLimitBurst = 30 * 1000000; # practically infinite
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -233,7 +233,7 @@ in
|
|||
type = types.str;
|
||||
default = "Check.Valid=1,Check.Unexpired=1";
|
||||
description = ''
|
||||
"Peer verification string". This may be used to adjust which TLS
|
||||
"Peer verification string". This may be used to adjust which TLS
|
||||
client certificates a server will accept, as a form of user
|
||||
authorization; for example, it may only accept TLS clients who
|
||||
offer a certificate abiding by some locality or organization name.
|
||||
|
|
|
@ -1,43 +1,121 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.services.openldap;
|
||||
legacyOptions = [ "rootpwFile" "suffix" "dataDir" "rootdn" "rootpw" ];
|
||||
openldap = cfg.package;
|
||||
configDir = if cfg.configDir != null then cfg.configDir else "/etc/openldap/slapd.d";
|
||||
|
||||
dataFile = pkgs.writeText "ldap-contents.ldif" cfg.declarativeContents;
|
||||
configFile = pkgs.writeText "slapd.conf" ((optionalString cfg.defaultSchemas ''
|
||||
include ${openldap.out}/etc/schema/core.schema
|
||||
include ${openldap.out}/etc/schema/cosine.schema
|
||||
include ${openldap.out}/etc/schema/inetorgperson.schema
|
||||
include ${openldap.out}/etc/schema/nis.schema
|
||||
'') + ''
|
||||
${cfg.extraConfig}
|
||||
database ${cfg.database}
|
||||
suffix ${cfg.suffix}
|
||||
rootdn ${cfg.rootdn}
|
||||
${if (cfg.rootpw != null) then ''
|
||||
rootpw ${cfg.rootpw}
|
||||
'' else ''
|
||||
include ${cfg.rootpwFile}
|
||||
''}
|
||||
directory ${cfg.dataDir}
|
||||
${cfg.extraDatabaseConfig}
|
||||
'');
|
||||
configOpts = if cfg.configDir == null then "-f ${configFile}"
|
||||
else "-F ${cfg.configDir}";
|
||||
in
|
||||
ldapValueType = let
|
||||
# Can't do types.either with multiple non-overlapping submodules, so define our own
|
||||
singleLdapValueType = lib.mkOptionType rec {
|
||||
name = "LDAP";
|
||||
description = "LDAP value";
|
||||
check = x: lib.isString x || (lib.isAttrs x && (x ? path || x ? base64));
|
||||
merge = lib.mergeEqualOption;
|
||||
};
|
||||
# We don't coerce to lists of single values, as some values must be unique
|
||||
in types.either singleLdapValueType (types.listOf singleLdapValueType);
|
||||
|
||||
{
|
||||
ldapAttrsType =
|
||||
let
|
||||
options = {
|
||||
attrs = mkOption {
|
||||
type = types.attrsOf ldapValueType;
|
||||
default = {};
|
||||
description = "Attributes of the parent entry.";
|
||||
};
|
||||
children = mkOption {
|
||||
# Hide the child attributes, to avoid infinite recursion in e.g. documentation
|
||||
# Actual Nix evaluation is lazy, so this is not an issue there
|
||||
type = let
|
||||
hiddenOptions = lib.mapAttrs (name: attr: attr // { visible = false; }) options;
|
||||
in types.attrsOf (types.submodule { options = hiddenOptions; });
|
||||
default = {};
|
||||
description = "Child entries of the current entry, with recursively the same structure.";
|
||||
example = lib.literalExample ''
|
||||
{
|
||||
"cn=schema" = {
|
||||
# The attribute used in the DN must be defined
|
||||
attrs = { cn = "schema"; };
|
||||
children = {
|
||||
# This entry's DN is expanded to "cn=foo,cn=schema"
|
||||
"cn=foo" = { ... };
|
||||
};
|
||||
# These includes are inserted after "cn=schema", but before "cn=foo,cn=schema"
|
||||
includes = [ ... ];
|
||||
};
|
||||
}
|
||||
'';
|
||||
};
|
||||
includes = mkOption {
|
||||
type = types.listOf types.path;
|
||||
default = [];
|
||||
description = ''
|
||||
LDIF files to include after the parent's attributes but before its children.
|
||||
'';
|
||||
};
|
||||
};
|
||||
in types.submodule { inherit options; };
|
||||
|
||||
###### interface
|
||||
valueToLdif = attr: values: let
|
||||
listValues = if lib.isList values then values else lib.singleton values;
|
||||
in map (value:
|
||||
if lib.isAttrs value then
|
||||
if lib.hasAttr "path" value
|
||||
then "${attr}:< file://${value.path}"
|
||||
else "${attr}:: ${value.base64}"
|
||||
else "${attr}: ${lib.replaceStrings [ "\n" ] [ "\n " ] value}"
|
||||
) listValues;
|
||||
|
||||
attrsToLdif = dn: { attrs, children, includes, ... }: [''
|
||||
dn: ${dn}
|
||||
${lib.concatStringsSep "\n" (lib.flatten (lib.mapAttrsToList valueToLdif attrs))}
|
||||
''] ++ (map (path: "include: file://${path}\n") includes) ++ (
|
||||
lib.flatten (lib.mapAttrsToList (name: value: attrsToLdif "${name},${dn}" value) children)
|
||||
);
|
||||
in {
|
||||
imports = let
|
||||
deprecationNote = "This option is removed due to the deprecation of `slapd.conf` upstream. Please migrate to `services.openldap.settings`, see the release notes for advice with this process.";
|
||||
mkDatabaseOption = old: new:
|
||||
lib.mkChangedOptionModule [ "services" "openldap" old ] [ "services" "openldap" "settings" "children" ]
|
||||
(config: let
|
||||
database = lib.getAttrFromPath [ "services" "openldap" "database" ] config;
|
||||
value = lib.getAttrFromPath [ "services" "openldap" old ] config;
|
||||
in lib.setAttrByPath ([ "olcDatabase={1}${database}" "attrs" ] ++ new) value);
|
||||
in [
|
||||
(lib.mkRemovedOptionModule [ "services" "openldap" "extraConfig" ] deprecationNote)
|
||||
(lib.mkRemovedOptionModule [ "services" "openldap" "extraDatabaseConfig" ] deprecationNote)
|
||||
|
||||
(lib.mkChangedOptionModule [ "services" "openldap" "logLevel" ] [ "services" "openldap" "settings" "attrs" "olcLogLevel" ]
|
||||
(config: lib.splitString " " (lib.getAttrFromPath [ "services" "openldap" "logLevel" ] config)))
|
||||
(lib.mkChangedOptionModule [ "services" "openldap" "defaultSchemas" ] [ "services" "openldap" "settings" "children" "cn=schema" "includes"]
|
||||
(config: lib.optionals (lib.getAttrFromPath [ "services" "openldap" "defaultSchemas" ] config) (
|
||||
map (schema: "${openldap}/etc/schema/${schema}.ldif") [ "core" "cosine" "inetorgperson" "nis" ])))
|
||||
|
||||
(lib.mkChangedOptionModule [ "services" "openldap" "database" ] [ "services" "openldap" "settings" "children" ]
|
||||
(config: let
|
||||
database = lib.getAttrFromPath [ "services" "openldap" "database" ] config;
|
||||
in {
|
||||
"olcDatabase={1}${database}".attrs = {
|
||||
# objectClass is case-insensitive, so don't need to capitalize ${database}
|
||||
objectClass = [ "olcdatabaseconfig" "olc${database}config" ];
|
||||
olcDatabase = "{1}${database}";
|
||||
olcDbDirectory = lib.mkDefault "/var/db/openldap";
|
||||
};
|
||||
"cn=schema".includes = lib.mkDefault (
|
||||
map (schema: "${openldap}/etc/schema/${schema}.ldif") [ "core" "cosine" "inetorgperson" "nis" ]
|
||||
);
|
||||
}))
|
||||
(mkDatabaseOption "rootpwFile" [ "olcRootPW" "path" ])
|
||||
(mkDatabaseOption "suffix" [ "olcSuffix" ])
|
||||
(mkDatabaseOption "dataDir" [ "olcDbDirectory" ])
|
||||
(mkDatabaseOption "rootdn" [ "olcRootDN" ])
|
||||
(mkDatabaseOption "rootpw" [ "olcRootPW" ])
|
||||
];
|
||||
options = {
|
||||
|
||||
services.openldap = {
|
||||
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
|
@ -77,224 +155,170 @@ in
|
|||
example = [ "ldaps:///" ];
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/db/openldap";
|
||||
description = "The database directory.";
|
||||
};
|
||||
|
||||
defaultSchemas = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Include the default schemas core, cosine, inetorgperson and nis.
|
||||
This setting will be ignored if configDir is set.
|
||||
settings = mkOption {
|
||||
type = ldapAttrsType;
|
||||
description = "Configuration for OpenLDAP, in OLC format";
|
||||
example = lib.literalExample ''
|
||||
{
|
||||
attrs.olcLogLevel = [ "stats" ];
|
||||
children = {
|
||||
"cn=schema".includes = [
|
||||
"\${pkgs.openldap}/etc/schema/core.ldif"
|
||||
"\${pkgs.openldap}/etc/schema/cosine.ldif"
|
||||
"\${pkgs.openldap}/etc/schema/inetorgperson.ldif"
|
||||
];
|
||||
"olcDatabase={-1}frontend" = {
|
||||
attrs = {
|
||||
objectClass = "olcDatabaseConfig";
|
||||
olcDatabase = "{-1}frontend";
|
||||
olcAccess = [ "{0}to * by dn.exact=uidNumber=0+gidNumber=0,cn=peercred,cn=external,cn=auth manage stop by * none stop" ];
|
||||
};
|
||||
};
|
||||
"olcDatabase={0}config" = {
|
||||
attrs = {
|
||||
objectClass = "olcDatabaseConfig";
|
||||
olcDatabase = "{0}config";
|
||||
olcAccess = [ "{0}to * by * none break" ];
|
||||
};
|
||||
};
|
||||
"olcDatabase={1}mdb" = {
|
||||
attrs = {
|
||||
objectClass = [ "olcDatabaseConfig" "olcMdbConfig" ];
|
||||
olcDatabase = "{1}mdb";
|
||||
olcDbDirectory = "/var/db/ldap";
|
||||
olcDbIndex = [
|
||||
"objectClass eq"
|
||||
"cn pres,eq"
|
||||
"uid pres,eq"
|
||||
"sn pres,eq,subany"
|
||||
];
|
||||
olcSuffix = "dc=example,dc=com";
|
||||
olcAccess = [ "{0}to * by * read break" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
'';
|
||||
};
|
||||
|
||||
database = mkOption {
|
||||
type = types.str;
|
||||
default = "mdb";
|
||||
description = ''
|
||||
Database type to use for the LDAP.
|
||||
This setting will be ignored if configDir is set.
|
||||
'';
|
||||
};
|
||||
|
||||
suffix = mkOption {
|
||||
type = types.str;
|
||||
example = "dc=example,dc=org";
|
||||
description = ''
|
||||
Specify the DN suffix of queries that will be passed to this backend
|
||||
database.
|
||||
This setting will be ignored if configDir is set.
|
||||
'';
|
||||
};
|
||||
|
||||
rootdn = mkOption {
|
||||
type = types.str;
|
||||
example = "cn=admin,dc=example,dc=org";
|
||||
description = ''
|
||||
Specify the distinguished name that is not subject to access control
|
||||
or administrative limit restrictions for operations on this database.
|
||||
This setting will be ignored if configDir is set.
|
||||
'';
|
||||
};
|
||||
|
||||
rootpw = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
Password for the root user.
|
||||
This setting will be ignored if configDir is set.
|
||||
Using this option will store the root password in plain text in the
|
||||
world-readable nix store. To avoid this the <literal>rootpwFile</literal> can be used.
|
||||
'';
|
||||
};
|
||||
|
||||
rootpwFile = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
Password file for the root user.
|
||||
The file should contain the string <literal>rootpw</literal> followed by the password.
|
||||
e.g.: <literal>rootpw mysecurepassword</literal>
|
||||
'';
|
||||
};
|
||||
|
||||
logLevel = mkOption {
|
||||
type = types.str;
|
||||
default = "0";
|
||||
example = "acl trace";
|
||||
description = "The log level selector of slapd.";
|
||||
};
|
||||
|
||||
# This option overrides settings
|
||||
configDir = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
description = "Use this optional config directory instead of using slapd.conf";
|
||||
description = ''
|
||||
Use this config directory instead of generating one from the
|
||||
<literal>settings</literal> option. Overrides all NixOS settings. If
|
||||
you use this option,ensure `olcPidFile` is set to `/run/slapd/slapd.conf`.
|
||||
'';
|
||||
example = "/var/db/slapd.d";
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = "
|
||||
slapd.conf configuration
|
||||
";
|
||||
example = literalExample ''
|
||||
'''
|
||||
include ${openldap.out}/etc/schema/core.schema
|
||||
include ${openldap.out}/etc/schema/cosine.schema
|
||||
include ${openldap.out}/etc/schema/inetorgperson.schema
|
||||
include ${openldap.out}/etc/schema/nis.schema
|
||||
|
||||
database bdb
|
||||
suffix dc=example,dc=org
|
||||
rootdn cn=admin,dc=example,dc=org
|
||||
# NOTE: change after first start
|
||||
rootpw secret
|
||||
directory /var/db/openldap
|
||||
'''
|
||||
'';
|
||||
};
|
||||
|
||||
declarativeContents = mkOption {
|
||||
type = with types; nullOr lines;
|
||||
default = null;
|
||||
type = with types; attrsOf lines;
|
||||
default = {};
|
||||
description = ''
|
||||
Declarative contents for the LDAP database, in LDIF format.
|
||||
Declarative contents for the LDAP database, in LDIF format by suffix.
|
||||
|
||||
Note a few facts when using it. First, the database
|
||||
<emphasis>must</emphasis> be stored in the directory defined by
|
||||
<code>dataDir</code>. Second, all <code>dataDir</code> will be erased
|
||||
when starting the LDAP server. Third, modifications to the database
|
||||
are not prevented, they are just dropped on the next reboot of the
|
||||
server. Finally, performance-wise the database and indexes are rebuilt
|
||||
on each server startup, so this will slow down server startup,
|
||||
All data will be erased when starting the LDAP server. Modifications
|
||||
to the database are not prevented, they are just dropped on the next
|
||||
reboot of the server. Performance-wise the database and indexes are
|
||||
rebuilt on each server startup, so this will slow down server startup,
|
||||
especially with large databases.
|
||||
'';
|
||||
example = ''
|
||||
dn: dc=example,dc=org
|
||||
objectClass: domain
|
||||
dc: example
|
||||
example = lib.literalExample ''
|
||||
{
|
||||
"dc=example,dc=org" = '''
|
||||
dn= dn: dc=example,dc=org
|
||||
objectClass: domain
|
||||
dc: example
|
||||
|
||||
dn: ou=users,dc=example,dc=org
|
||||
objectClass = organizationalUnit
|
||||
ou: users
|
||||
dn: ou=users,dc=example,dc=org
|
||||
objectClass = organizationalUnit
|
||||
ou: users
|
||||
|
||||
# ...
|
||||
# ...
|
||||
''';
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
extraDatabaseConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
slapd.conf configuration after the database option.
|
||||
This setting will be ignored if configDir is set.
|
||||
'';
|
||||
example = ''
|
||||
# Indices to maintain for this directory
|
||||
# unique id so equality match only
|
||||
index uid eq
|
||||
# allows general searching on commonname, givenname and email
|
||||
index cn,gn,mail eq,sub
|
||||
# allows multiple variants on surname searching
|
||||
index sn eq,sub
|
||||
# sub above includes subintial,subany,subfinal
|
||||
# optimise department searches
|
||||
index ou eq
|
||||
# if searches will include objectClass uncomment following
|
||||
# index objectClass eq
|
||||
# shows use of default index parameter
|
||||
index default eq,sub
|
||||
# indices missing - uses default eq,sub
|
||||
index telephonenumber
|
||||
|
||||
# other database parameters
|
||||
# read more in slapd.conf reference section
|
||||
cachesize 10000
|
||||
checkpoint 128 15
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
meta = {
|
||||
maintainers = [ lib.maintainers.mic92 ];
|
||||
};
|
||||
|
||||
|
||||
###### implementation
|
||||
meta.maintainers = with lib.maintainters; [ mic92 kwohlfahrt ];
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = cfg.configDir != null || cfg.rootpwFile != null || cfg.rootpw != null;
|
||||
message = "services.openldap: Unless configDir is set, either rootpw or rootpwFile must be set";
|
||||
}
|
||||
];
|
||||
|
||||
assertions = map (opt: {
|
||||
assertion = ((getAttr opt cfg) != "_mkMergedOptionModule") -> (cfg.database != "_mkMergedOptionModule");
|
||||
message = "Legacy OpenLDAP option `services.openldap.${opt}` requires `services.openldap.database` (use value \"mdb\" if unsure)";
|
||||
}) legacyOptions;
|
||||
environment.systemPackages = [ openldap ];
|
||||
|
||||
# Literal attributes must always be set
|
||||
services.openldap.settings = {
|
||||
attrs = {
|
||||
objectClass = "olcGlobal";
|
||||
cn = "config";
|
||||
olcPidFile = "/run/slapd/slapd.pid";
|
||||
};
|
||||
children."cn=schema".attrs = {
|
||||
cn = "schema";
|
||||
objectClass = "olcSchemaConfig";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.openldap = {
|
||||
description = "LDAP server";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
preStart = ''
|
||||
preStart = let
|
||||
settingsFile = pkgs.writeText "config.ldif" (lib.concatStringsSep "\n" (attrsToLdif "cn=config" cfg.settings));
|
||||
|
||||
dbSettings = lib.filterAttrs (name: value: lib.hasPrefix "olcDatabase=" name) cfg.settings.children;
|
||||
dataDirs = lib.mapAttrs' (name: value: lib.nameValuePair value.attrs.olcSuffix value.attrs.olcDbDirectory)
|
||||
(lib.filterAttrs (_: value: value.attrs ? olcDbDirectory) dbSettings);
|
||||
dataFiles = lib.mapAttrs (dn: contents: pkgs.writeText "${dn}.ldif" contents) cfg.declarativeContents;
|
||||
mkLoadScript = dn: let
|
||||
dataDir = lib.escapeShellArg (getAttr dn dataDirs);
|
||||
in ''
|
||||
rm -rf ${dataDir}/*
|
||||
${openldap}/bin/slapadd -F ${lib.escapeShellArg configDir} -b ${dn} -l ${getAttr dn dataFiles}
|
||||
chown -R "${cfg.user}:${cfg.group}" ${dataDir}
|
||||
'';
|
||||
in ''
|
||||
mkdir -p /run/slapd
|
||||
chown -R "${cfg.user}:${cfg.group}" /run/slapd
|
||||
${optionalString (cfg.declarativeContents != null) ''
|
||||
rm -Rf "${cfg.dataDir}"
|
||||
''}
|
||||
mkdir -p "${cfg.dataDir}"
|
||||
${optionalString (cfg.declarativeContents != null) ''
|
||||
${openldap.out}/bin/slapadd ${configOpts} -l ${dataFile}
|
||||
''}
|
||||
chown -R "${cfg.user}:${cfg.group}" "${cfg.dataDir}"
|
||||
|
||||
${openldap}/bin/slaptest ${configOpts}
|
||||
mkdir -p ${lib.escapeShellArg configDir} ${lib.escapeShellArgs (lib.attrValues dataDirs)}
|
||||
chown "${cfg.user}:${cfg.group}" ${lib.escapeShellArg configDir} ${lib.escapeShellArgs (lib.attrValues dataDirs)}
|
||||
|
||||
${lib.optionalString (cfg.configDir == null) (''
|
||||
rm -Rf ${configDir}/*
|
||||
${openldap}/bin/slapadd -F ${configDir} -bcn=config -l ${settingsFile}
|
||||
'')}
|
||||
chown -R "${cfg.user}:${cfg.group}" ${lib.escapeShellArg configDir}
|
||||
|
||||
${lib.concatStrings (map mkLoadScript (lib.attrNames cfg.declarativeContents))}
|
||||
${openldap}/bin/slaptest -u -F ${lib.escapeShellArg configDir}
|
||||
'';
|
||||
serviceConfig.ExecStart =
|
||||
"${openldap.out}/libexec/slapd -d '${cfg.logLevel}' " +
|
||||
"-u '${cfg.user}' -g '${cfg.group}' " +
|
||||
"-h '${concatStringsSep " " cfg.urlList}' " +
|
||||
"${configOpts}";
|
||||
serviceConfig = {
|
||||
ExecStart = lib.escapeShellArgs ([
|
||||
"${openldap}/libexec/slapd" "-u" cfg.user "-g" cfg.group "-F" configDir
|
||||
"-h" (lib.concatStringsSep " " cfg.urlList)
|
||||
]);
|
||||
Type = "forking";
|
||||
PIDFile = cfg.settings.attrs.olcPidFile;
|
||||
};
|
||||
};
|
||||
|
||||
users.users.openldap =
|
||||
{ name = cfg.user;
|
||||
users.users = lib.optionalAttrs (cfg.user == "openldap") {
|
||||
openldap = {
|
||||
group = cfg.group;
|
||||
uid = config.ids.uids.openldap;
|
||||
};
|
||||
|
||||
users.groups.openldap =
|
||||
{ name = cfg.group;
|
||||
gid = config.ids.gids.openldap;
|
||||
isSystemUser = true;
|
||||
};
|
||||
};
|
||||
|
||||
users.groups = lib.optionalAttrs (cfg.group == "openldap") {
|
||||
openldap = {};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -69,11 +69,16 @@ in
|
|||
type = types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Defines how users authenticate themselves to the server. By
|
||||
default, "trust" access to local users will always be granted
|
||||
along with any other custom options. If you do not want this,
|
||||
set this option using "lib.mkForce" to override this
|
||||
behaviour.
|
||||
Defines how users authenticate themselves to the server. See the
|
||||
<link xlink:href="https://www.postgresql.org/docs/current/auth-pg-hba-conf.html">
|
||||
PostgreSQL documentation for pg_hba.conf</link>
|
||||
for details on the expected format of this option. By default,
|
||||
peer based authentication will be used for users connecting
|
||||
via the Unix socket, and md5 password authentication will be
|
||||
used for users connecting via TCP. Any added rules will be
|
||||
inserted above the default rules. If you'd like to replace the
|
||||
default rules entirely, you can use <function>lib.mkForce</function> in your
|
||||
module.
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
@ -87,9 +87,12 @@ in
|
|||
|
||||
bind = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null; # All interfaces
|
||||
description = "The IP interface to bind to.";
|
||||
example = "127.0.0.1";
|
||||
default = "127.0.0.1";
|
||||
description = ''
|
||||
The IP interface to bind to.
|
||||
<literal>null</literal> means "all interfaces".
|
||||
'';
|
||||
example = "192.0.2.1";
|
||||
};
|
||||
|
||||
unixSocket = mkOption {
|
||||
|
|
|
@ -1,202 +0,0 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.services.riak-cs;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
###### interface
|
||||
|
||||
options = {
|
||||
|
||||
services.riak-cs = {
|
||||
|
||||
enable = mkEnableOption "riak-cs";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.riak-cs;
|
||||
defaultText = "pkgs.riak-cs";
|
||||
example = literalExample "pkgs.riak-cs";
|
||||
description = ''
|
||||
Riak package to use.
|
||||
'';
|
||||
};
|
||||
|
||||
nodeName = mkOption {
|
||||
type = types.str;
|
||||
default = "riak-cs@127.0.0.1";
|
||||
description = ''
|
||||
Name of the Erlang node.
|
||||
'';
|
||||
};
|
||||
|
||||
anonymousUserCreation = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Anonymous user creation.
|
||||
'';
|
||||
};
|
||||
|
||||
riakHost = mkOption {
|
||||
type = types.str;
|
||||
default = "127.0.0.1:8087";
|
||||
description = ''
|
||||
Name of riak hosting service.
|
||||
'';
|
||||
};
|
||||
|
||||
listener = mkOption {
|
||||
type = types.str;
|
||||
default = "127.0.0.1:8080";
|
||||
description = ''
|
||||
Name of Riak CS listening service.
|
||||
'';
|
||||
};
|
||||
|
||||
stanchionHost = mkOption {
|
||||
type = types.str;
|
||||
default = "127.0.0.1:8085";
|
||||
description = ''
|
||||
Name of stanchion hosting service.
|
||||
'';
|
||||
};
|
||||
|
||||
stanchionSsl = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Tell stanchion to use SSL.
|
||||
'';
|
||||
};
|
||||
|
||||
distributedCookie = mkOption {
|
||||
type = types.str;
|
||||
default = "riak";
|
||||
description = ''
|
||||
Cookie for distributed node communication. All nodes in the
|
||||
same cluster should use the same cookie or they will not be able to
|
||||
communicate.
|
||||
'';
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/db/riak-cs";
|
||||
description = ''
|
||||
Data directory for Riak CS.
|
||||
'';
|
||||
};
|
||||
|
||||
logDir = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/log/riak-cs";
|
||||
description = ''
|
||||
Log directory for Riak CS.
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Additional text to be appended to <filename>riak-cs.conf</filename>.
|
||||
'';
|
||||
};
|
||||
|
||||
extraAdvancedConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Additional text to be appended to <filename>advanced.config</filename>.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
###### implementation
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
environment.etc."riak-cs/riak-cs.conf".text = ''
|
||||
nodename = ${cfg.nodeName}
|
||||
distributed_cookie = ${cfg.distributedCookie}
|
||||
|
||||
platform_log_dir = ${cfg.logDir}
|
||||
|
||||
riak_host = ${cfg.riakHost}
|
||||
listener = ${cfg.listener}
|
||||
stanchion_host = ${cfg.stanchionHost}
|
||||
|
||||
anonymous_user_creation = ${if cfg.anonymousUserCreation then "on" else "off"}
|
||||
|
||||
${cfg.extraConfig}
|
||||
'';
|
||||
|
||||
environment.etc."riak-cs/advanced.config".text = ''
|
||||
${cfg.extraAdvancedConfig}
|
||||
'';
|
||||
|
||||
users.users.riak-cs = {
|
||||
name = "riak-cs";
|
||||
uid = config.ids.uids.riak-cs;
|
||||
group = "riak";
|
||||
description = "Riak CS server user";
|
||||
};
|
||||
|
||||
systemd.services.riak-cs = {
|
||||
description = "Riak CS Server";
|
||||
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
|
||||
path = [
|
||||
pkgs.utillinux # for `logger`
|
||||
pkgs.bash
|
||||
];
|
||||
|
||||
environment.HOME = "${cfg.dataDir}";
|
||||
environment.RIAK_CS_DATA_DIR = "${cfg.dataDir}";
|
||||
environment.RIAK_CS_LOG_DIR = "${cfg.logDir}";
|
||||
environment.RIAK_CS_ETC_DIR = "/etc/riak";
|
||||
|
||||
preStart = ''
|
||||
if ! test -e ${cfg.logDir}; then
|
||||
mkdir -m 0755 -p ${cfg.logDir}
|
||||
chown -R riak-cs ${cfg.logDir}
|
||||
fi
|
||||
|
||||
if ! test -e ${cfg.dataDir}; then
|
||||
mkdir -m 0700 -p ${cfg.dataDir}
|
||||
chown -R riak-cs ${cfg.dataDir}
|
||||
fi
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "${cfg.package}/bin/riak-cs console";
|
||||
ExecStop = "${cfg.package}/bin/riak-cs stop";
|
||||
StandardInput = "tty";
|
||||
User = "riak-cs";
|
||||
Group = "riak-cs";
|
||||
PermissionsStartOnly = true;
|
||||
# Give Riak a decent amount of time to clean up.
|
||||
TimeoutStopSec = 120;
|
||||
LimitNOFILE = 65536;
|
||||
};
|
||||
|
||||
unitConfig.RequiresMountsFor = [
|
||||
"${cfg.dataDir}"
|
||||
"${cfg.logDir}"
|
||||
"/etc/riak"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
|
@ -118,7 +118,7 @@ in
|
|||
after = [ "network.target" ];
|
||||
|
||||
path = [
|
||||
pkgs.utillinux # for `logger`
|
||||
pkgs.util-linux # for `logger`
|
||||
pkgs.bash
|
||||
];
|
||||
|
||||
|
|
|
@ -1,194 +0,0 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.services.stanchion;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
###### interface
|
||||
|
||||
options = {
|
||||
|
||||
services.stanchion = {
|
||||
|
||||
enable = mkEnableOption "stanchion";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.stanchion;
|
||||
defaultText = "pkgs.stanchion";
|
||||
example = literalExample "pkgs.stanchion";
|
||||
description = ''
|
||||
Stanchion package to use.
|
||||
'';
|
||||
};
|
||||
|
||||
nodeName = mkOption {
|
||||
type = types.str;
|
||||
default = "stanchion@127.0.0.1";
|
||||
description = ''
|
||||
Name of the Erlang node.
|
||||
'';
|
||||
};
|
||||
|
||||
adminKey = mkOption {
|
||||
type = types.str;
|
||||
default = "";
|
||||
description = ''
|
||||
Name of admin user.
|
||||
'';
|
||||
};
|
||||
|
||||
adminSecret = mkOption {
|
||||
type = types.str;
|
||||
default = "";
|
||||
description = ''
|
||||
Name of admin secret
|
||||
'';
|
||||
};
|
||||
|
||||
riakHost = mkOption {
|
||||
type = types.str;
|
||||
default = "127.0.0.1:8087";
|
||||
description = ''
|
||||
Name of riak hosting service.
|
||||
'';
|
||||
};
|
||||
|
||||
listener = mkOption {
|
||||
type = types.str;
|
||||
default = "127.0.0.1:8085";
|
||||
description = ''
|
||||
Name of Riak CS listening service.
|
||||
'';
|
||||
};
|
||||
|
||||
stanchionHost = mkOption {
|
||||
type = types.str;
|
||||
default = "127.0.0.1:8085";
|
||||
description = ''
|
||||
Name of stanchion hosting service.
|
||||
'';
|
||||
};
|
||||
|
||||
distributedCookie = mkOption {
|
||||
type = types.str;
|
||||
default = "riak";
|
||||
description = ''
|
||||
Cookie for distributed node communication. All nodes in the
|
||||
same cluster should use the same cookie or they will not be able to
|
||||
communicate.
|
||||
'';
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/db/stanchion";
|
||||
description = ''
|
||||
Data directory for Stanchion.
|
||||
'';
|
||||
};
|
||||
|
||||
logDir = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/log/stanchion";
|
||||
description = ''
|
||||
Log directory for Stanchion.
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Additional text to be appended to <filename>stanchion.conf</filename>.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
###### implementation
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
|
||||
environment.etc."stanchion/advanced.config".text = ''
|
||||
[{stanchion, []}].
|
||||
'';
|
||||
|
||||
environment.etc."stanchion/stanchion.conf".text = ''
|
||||
listener = ${cfg.listener}
|
||||
|
||||
riak_host = ${cfg.riakHost}
|
||||
|
||||
${optionalString (cfg.adminKey == "") "#"} admin.key=${optionalString (cfg.adminKey != "") cfg.adminKey}
|
||||
${optionalString (cfg.adminSecret == "") "#"} admin.secret=${optionalString (cfg.adminSecret != "") cfg.adminSecret}
|
||||
|
||||
platform_bin_dir = ${pkgs.stanchion}/bin
|
||||
platform_data_dir = ${cfg.dataDir}
|
||||
platform_etc_dir = /etc/stanchion
|
||||
platform_lib_dir = ${pkgs.stanchion}/lib
|
||||
platform_log_dir = ${cfg.logDir}
|
||||
|
||||
nodename = ${cfg.nodeName}
|
||||
|
||||
distributed_cookie = ${cfg.distributedCookie}
|
||||
|
||||
${cfg.extraConfig}
|
||||
'';
|
||||
|
||||
users.users.stanchion = {
|
||||
name = "stanchion";
|
||||
uid = config.ids.uids.stanchion;
|
||||
group = "stanchion";
|
||||
description = "Stanchion server user";
|
||||
};
|
||||
|
||||
users.groups.stanchion.gid = config.ids.gids.stanchion;
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d '${cfg.logDir}' - stanchion stanchion --"
|
||||
"d '${cfg.dataDir}' 0700 stanchion stanchion --"
|
||||
];
|
||||
|
||||
systemd.services.stanchion = {
|
||||
description = "Stanchion Server";
|
||||
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
|
||||
path = [
|
||||
pkgs.utillinux # for `logger`
|
||||
pkgs.bash
|
||||
];
|
||||
|
||||
environment.HOME = "${cfg.dataDir}";
|
||||
environment.STANCHION_DATA_DIR = "${cfg.dataDir}";
|
||||
environment.STANCHION_LOG_DIR = "${cfg.logDir}";
|
||||
environment.STANCHION_ETC_DIR = "/etc/stanchion";
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "${cfg.package}/bin/stanchion console";
|
||||
ExecStop = "${cfg.package}/bin/stanchion stop";
|
||||
StandardInput = "tty";
|
||||
User = "stanchion";
|
||||
Group = "stanchion";
|
||||
# Give Stanchion a decent amount of time to clean up.
|
||||
TimeoutStopSec = 120;
|
||||
LimitNOFILE = 65536;
|
||||
};
|
||||
|
||||
unitConfig.RequiresMountsFor = [
|
||||
"${cfg.dataDir}"
|
||||
"${cfg.logDir}"
|
||||
"/etc/stanchion"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
|
@ -40,10 +40,10 @@ let cfg = config.services.victoriametrics; in
|
|||
systemd.services.victoriametrics = {
|
||||
description = "VictoriaMetrics time series database";
|
||||
after = [ "network.target" ];
|
||||
startLimitBurst = 5;
|
||||
serviceConfig = {
|
||||
Restart = "on-failure";
|
||||
RestartSec = 1;
|
||||
StartLimitBurst = 5;
|
||||
StateDirectory = "victoriametrics";
|
||||
DynamicUser = true;
|
||||
ExecStart = ''
|
||||
|
|
|
@ -17,10 +17,6 @@ let
|
|||
mkdir -p "$out/lib"
|
||||
ln -s "${pkgs.pipewire.jack}/lib" "$out/lib/pipewire"
|
||||
'';
|
||||
pulse-libs = pkgs.runCommand "pulse-libs" {} ''
|
||||
mkdir -p "$out/lib"
|
||||
ln -s "${pkgs.pipewire.pulse}/lib" "$out/lib/pipewire"
|
||||
'';
|
||||
in {
|
||||
|
||||
meta = {
|
||||
|
@ -50,7 +46,7 @@ in {
|
|||
};
|
||||
|
||||
pulse = {
|
||||
enable = mkEnableOption "PulseAudio emulation";
|
||||
enable = mkEnableOption "PulseAudio server emulation";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -61,23 +57,24 @@ in {
|
|||
assertions = [
|
||||
{
|
||||
assertion = cfg.pulse.enable -> !config.hardware.pulseaudio.enable;
|
||||
message = "PipeWire based PulseAudio emulation doesn't use the PulseAudio service";
|
||||
message = "PipeWire based PulseAudio server emulation replaces PulseAudio";
|
||||
}
|
||||
{
|
||||
assertion = cfg.jack.enable -> !config.services.jack.jackd.enable;
|
||||
message = "PIpeWire based JACK emulation doesn't use the JACK service";
|
||||
message = "PipeWire based JACK emulation doesn't use the JACK service";
|
||||
}
|
||||
];
|
||||
|
||||
environment.systemPackages = [ pkgs.pipewire ]
|
||||
++ lib.optional cfg.jack.enable jack-libs
|
||||
++ lib.optional cfg.pulse.enable pulse-libs;
|
||||
++ lib.optional cfg.jack.enable jack-libs;
|
||||
|
||||
systemd.packages = [ pkgs.pipewire ];
|
||||
systemd.packages = [ pkgs.pipewire ]
|
||||
++ lib.optional cfg.pulse.enable pkgs.pipewire.pulse;
|
||||
|
||||
# PipeWire depends on DBUS but doesn't list it. Without this booting
|
||||
# into a terminal results in the service crashing with an error.
|
||||
systemd.user.sockets.pipewire.wantedBy = lib.mkIf cfg.socketActivation [ "sockets.target" ];
|
||||
systemd.user.sockets.pipewire-pulse.wantedBy = lib.mkIf (cfg.socketActivation && cfg.pulse.enable) ["sockets.target"];
|
||||
systemd.user.services.pipewire.bindsTo = [ "dbus.service" ];
|
||||
services.udev.packages = [ pkgs.pipewire ];
|
||||
|
||||
|
@ -100,6 +97,6 @@ in {
|
|||
source = "${pkgs.pipewire}/share/alsa/alsa.conf.d/50-pipewire.conf";
|
||||
};
|
||||
environment.sessionVariables.LD_LIBRARY_PATH =
|
||||
lib.optional (cfg.jack.enable || cfg.pulse.enable) "/run/current-system/sw/lib/pipewire";
|
||||
lib.optional cfg.jack.enable "/run/current-system/sw/lib/pipewire";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ in {
|
|||
description = "Profile Sync daemon";
|
||||
wants = [ "psd-resync.service" ];
|
||||
wantedBy = [ "default.target" ];
|
||||
path = with pkgs; [ rsync kmod gawk nettools utillinux profile-sync-daemon ];
|
||||
path = with pkgs; [ rsync kmod gawk nettools util-linux profile-sync-daemon ];
|
||||
unitConfig = {
|
||||
RequiresMountsFor = [ "/home/" ];
|
||||
};
|
||||
|
@ -55,7 +55,7 @@ in {
|
|||
wants = [ "psd-resync.timer" ];
|
||||
partOf = [ "psd.service" ];
|
||||
wantedBy = [ "default.target" ];
|
||||
path = with pkgs; [ rsync kmod gawk nettools utillinux profile-sync-daemon ];
|
||||
path = with pkgs; [ rsync kmod gawk nettools util-linux profile-sync-daemon ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${pkgs.profile-sync-daemon}/bin/profile-sync-daemon resync";
|
||||
|
|
|
@ -38,6 +38,11 @@ with lib;
|
|||
|
||||
services.dbus.packages = [ pkgs.telepathy-mission-control ];
|
||||
|
||||
# Enable runtime optional telepathy in gnome-shell
|
||||
services.xserver.desktopManager.gnome3.sessionPath = with pkgs; [
|
||||
telepathy-glib
|
||||
telepathy-logger
|
||||
];
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue