add flake support

This commit is contained in:
Naïm Favier 2020-12-15 16:01:40 +01:00
parent 7c06f610f1
commit ae89eafb81
No known key found for this signature in database
GPG Key ID: 49B07322580B7EE2
5 changed files with 98 additions and 12 deletions

View File

@ -97,6 +97,34 @@ After a ``nixos-rebuild switch --upgrade`` your server should be good to
go. If you want to use ``nixops`` to deploy the server, look in the
subfolder ``nixops`` for some inspiration.
If you're using `flakes <https://nixos.wiki/wiki/Flakes>`__, you can use
the following minimal ``flake.nix`` as an example:
.. code:: nix
{
description = "NixOS configuration";
inputs.simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver";
outputs = { self, nixpkgs, simple-nixos-mailserver }: {
nixosConfigurations = {
hostname = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
simple-nixos-mailserver.nixosModule
{
mailserver = {
enable = true;
# ...
};
}
];
};
};
};
}
B) Setup everything else
~~~~~~~~~~~~~~~~~~~~~~~~

42
flake.lock Normal file
View File

@ -0,0 +1,42 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1607522989,
"narHash": "sha256-o/jWhOSAlaK7y2M57OIriRt6whuVVocS/T0mG7fd1TI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e9158eca70ae59e73fae23be5d13d3fa0cfc78b4",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"utils": {
"locked": {
"lastModified": 1605370193,
"narHash": "sha256-YyMTf3URDL/otKdKgtoMChu4vfVL3vCMkRqpGifhUn0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5021eac20303a61fafe17224c087f5519baed54d",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

26
flake.nix Normal file
View File

@ -0,0 +1,26 @@
{
description = "A complete and Simple Nixos Mailserver";
inputs = {
utils.url = "github:numtide/flake-utils";
nixpkgs.url = "flake:nixpkgs/nixos-unstable";
};
outputs = { self, utils, nixpkgs }: {
nixosModules.mailserver = import ./.;
nixosModule = self.nixosModules.mailserver;
} // utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
(python3.withPackages (p: with p; [
sphinx
sphinx_rtd_theme
]))
jq
clamav
];
};
});
}

View File

@ -5,7 +5,7 @@
{ config, pkgs, ... }:
{
imports = [
./../default.nix
../default.nix
];
mailserver = {

View File

@ -1,11 +1 @@
let
nixpkgs = (import ./nix/sources.nix).nixpkgs-unstable;
pkgs = import nixpkgs {};
in
pkgs.mkShell {
buildInputs = with pkgs; [
(python3.withPackages(p: [p.sphinx p.sphinx_rtd_theme]))
niv
jq clamav
];
}
(import (builtins.fetchGit "https://github.com/edolstra/flake-compat") { src = ./.; }).shellNix