summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaïm Favier <n@monade.li>2020-12-15 16:01:40 +0100
committerNaïm Favier <n@monade.li>2020-12-15 16:14:44 +0100
commitae89eafb817f6c691cb0e97f9e67cd9204ada3a4 (patch)
treea2e64d1c337e2e28514a2244b966417cff3e0aaf
parent7c06f610f15642e3664f01a51c08c64cc8835f51 (diff)
add flake support
-rw-r--r--docs/setup-guide.rst28
-rw-r--r--flake.lock42
-rw-r--r--flake.nix26
-rw-r--r--nixops/single-server.nix2
-rw-r--r--shell.nix12
5 files changed, 98 insertions, 12 deletions
diff --git a/docs/setup-guide.rst b/docs/setup-guide.rst
index ef2a76b..cc53283 100644
--- a/docs/setup-guide.rst
+++ b/docs/setup-guide.rst
@@ -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
~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..a9abdbc
--- /dev/null
+++ b/flake.lock
@@ -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
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..3d8cfbe
--- /dev/null
+++ b/flake.nix
@@ -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
+ ];
+ };
+ });
+}
diff --git a/nixops/single-server.nix b/nixops/single-server.nix
index 115c593..c002da7 100644
--- a/nixops/single-server.nix
+++ b/nixops/single-server.nix
@@ -5,7 +5,7 @@
{ config, pkgs, ... }:
{
imports = [
- ./../default.nix
+ ../default.nix
];
mailserver = {
diff --git a/shell.nix b/shell.nix
index 2c06231..d32886e 100644
--- a/shell.nix
+++ b/shell.nix
@@ -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