summaryrefslogtreecommitdiff
path: root/examples/nixos
diff options
context:
space:
mode:
Diffstat (limited to 'examples/nixos')
-rw-r--r--examples/nixos/.gitignore2
-rw-r--r--examples/nixos/README.md13
-rw-r--r--examples/nixos/flake.nix51
3 files changed, 66 insertions, 0 deletions
diff --git a/examples/nixos/.gitignore b/examples/nixos/.gitignore
new file mode 100644
index 0000000..abd4cf1
--- /dev/null
+++ b/examples/nixos/.gitignore
@@ -0,0 +1,2 @@
+/flake.lock
+/nixos.qcow2
diff --git a/examples/nixos/README.md b/examples/nixos/README.md
new file mode 100644
index 0000000..ea6b9f4
--- /dev/null
+++ b/examples/nixos/README.md
@@ -0,0 +1,13 @@
+# NixOS example
+
+This example shows how to install `temp-postgres` on NixOS using Nix flakes.
+
+You can actually run this configuration as a virtual machine on QEMU:
+
+```sh
+# Use the latest version of temp-postgres.
+nix run ".#nixosConfigurations.myhost.config.system.build.vm"
+
+# Use the worktree version of temp-postgres.
+nix run --override-input temp-postgres ../.. ".#nixosConfigurations.myhost.config.system.build.vm"
+```
diff --git a/examples/nixos/flake.nix b/examples/nixos/flake.nix
new file mode 100644
index 0000000..f97422c
--- /dev/null
+++ b/examples/nixos/flake.nix
@@ -0,0 +1,51 @@
+{
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
+
+ temp-postgres = {
+ # Try adding "?ref=main&shallow=0" to the URL if you experience caching issues.
+ url = "git+https://git.skreutz.com/temp-postgres.git";
+ # Optionally use your global Nixpkgs input.
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ };
+
+ outputs =
+ {
+ self,
+ nixpkgs,
+ temp-postgres,
+ }@inputs:
+ {
+ nixosConfigurations.myhost =
+ let
+ system = "x86_64-linux";
+ in
+ nixpkgs.lib.nixosSystem {
+ inherit system;
+ specialArgs = {
+ inherit system inputs;
+ };
+ modules = [
+ # The following goes typically into ./configuration.nix
+ {
+ environment.systemPackages = [ inputs.temp-postgres.packages.${system}.default ];
+
+ users.users.stefan = {
+ isNormalUser = true;
+ extraGroups = [ "wheel" ];
+ initialPassword = "sesame";
+ };
+ system.stateVersion = "26.05";
+
+ # Dummy values to avoid failed assertions during `nix flake check`.
+ fileSystems."/" = {
+ device = "/dev/null";
+ fsType = "ext4";
+ };
+ boot.loader.grub.devices = [ "/dev/null" ];
+ }
+ ];
+ };
+ };
+}
Generated by cgit. See skreutz.com for my tech blog and contact information.