From: Valentin Kharin <valentin.kharin@unikie.com>
To: devel@spectrum-os.org
Cc: Valentin Kharin <valentin.kharin@unikie.com>
Subject: [PATCH 1/2] Add flakes support
Date: Wed, 14 Dec 2022 13:09:53 +0200 [thread overview]
Message-ID: <20221214110954.141676-1-valentin.kharin@unikie.com> (raw)
Signed-off-by: Valentin Kharin <valentin.kharin@unikie.com>
---
flake.lock | 43 +++++++++++++++++++++++++++++++++
flake.nix | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 114 insertions(+)
create mode 100644 flake.lock
create mode 100644 flake.nix
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..aa4ee5e
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,43 @@
+{
+ "nodes": {
+ "flake-utils": {
+ "locked": {
+ "lastModified": 1667395993,
+ "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1669635185,
+ "narHash": "sha256-vYg6GjnsEWNWt/4TmfFN9WtQmSXb4S796J2UOfyTcW0=",
+ "ref": "refs/heads/rootfs",
+ "rev": "3176ddef4b4cec85faa2f49d29ce74816d452dc0",
+ "revCount": 429673,
+ "type": "git",
+ "url": "https://spectrum-os.org/git/nixpkgs/"
+ },
+ "original": {
+ "ref": "refs/heads/rootfs",
+ "type": "git",
+ "url": "https://spectrum-os.org/git/nixpkgs/"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-utils": "flake-utils",
+ "nixpkgs": "nixpkgs"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..6e77006
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,71 @@
+{
+ description = "A compartmentalized operating system";
+
+ # NOTE: Revision specification format is ?ref=refs%2fheads%2f<BRANCH>&rev=<COMMIT_REVISION>
+ inputs.nixpkgs.url =
+ "git+https://spectrum-os.org/git/nixpkgs/?ref=refs%2fheads%2frootfs";
+ inputs.flake-utils.url = "github:numtide/flake-utils";
+
+ outputs = { self, nixpkgs, flake-utils }:
+ flake-utils.lib.eachDefaultSystem (system:
+ let
+ pkgs = nixpkgs.legacyPackages.${system};
+ config = { inherit pkgs; };
+ lib = pkgs.lib;
+
+ mkEntryPoint = { name ? builtins.baseNameOf path, path
+ , enableShell ? true, enablePackage ? true }:
+ let
+ shell = {
+ # NOTE: https://stackoverflow.com/a/43850372
+ devShells.${name} =
+ import (path + "/shell.nix") { inherit config; };
+ };
+ package = { packages.${name} = import path { inherit config; }; };
+ in (if enableShell then shell else { })
+ // (if enablePackage then package else { });
+
+ # Entry point is a directory with shell.nix and default.nix
+ # This function maps every entry point to corresponding devShell and package
+ mapEntryPoints = epoints:
+ builtins.foldl' lib.recursiveUpdate { } (map mkEntryPoint epoints);
+ in lib.recursiveUpdate (mapEntryPoints [
+ {
+ path = ./.;
+ enablePackage = false;
+ }
+ { path = ./host/initramfs; }
+ { path = ./host/rootfs; }
+ { path = ./host/start-vm; }
+ { path = ./img/app; }
+ { path = ./release/live; }
+ { path = ./vm/sys/net; }
+ ]) {
+ # Add some other flake schema related stuff here.
+ # NOTE: flake-utils.lib.eachDefaultSystem automagically adds ${system}.
+ devShells.documentation = import ./Documentation { inherit config; };
+ packages.documentation = import ./Documentation { inherit config; };
+
+ nixosModules = let
+ substituters = [ "https://cache.dataaturservice.se/spectrum/" ];
+ trusted-public-keys = [
+ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
+ "spectrum-os.org-1:rnnSumz3+Dbs5uewPlwZSTP0k3g/5SRG4hD7Wbr9YuQ="
+ ];
+ in {
+ # NOTE: See https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-substituters
+ # and https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-trusted-substituters
+ # to understand difference between these two modules.
+ binary-cache = { ... }: {
+ nix.settings = { inherit trusted-public-keys substituters; };
+ };
+ # Doesn't enabled by
+ trusted-binary-cache = { ... }: {
+ nix.settings = {
+ inherit trusted-public-keys;
+ trusted-substituters = substituters;
+ };
+ };
+ };
+ });
+}
--
2.38.1
next reply other threads:[~2022-12-14 11:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-14 11:09 Valentin Kharin [this message]
2022-12-14 11:09 ` [PATCH 2/2] Documentation: flakes Valentin Kharin
2022-12-21 11:21 ` Alyssa Ross
2022-12-21 11:19 ` [PATCH 1/2] Add flakes support Alyssa Ross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221214110954.141676-1-valentin.kharin@unikie.com \
--to=valentin.kharin@unikie.com \
--cc=devel@spectrum-os.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://spectrum-os.org/git/crosvm
https://spectrum-os.org/git/doc
https://spectrum-os.org/git/mktuntap
https://spectrum-os.org/git/nixpkgs
https://spectrum-os.org/git/spectrum
https://spectrum-os.org/git/ucspi-vsock
https://spectrum-os.org/git/www
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).