diff options
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | examples/nixos/.gitignore | 2 | ||||
| -rw-r--r-- | examples/nixos/README.md | 13 | ||||
| -rw-r--r-- | examples/nixos/flake.nix | 51 |
5 files changed, 69 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index a546a2a..ca316f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep A Changelog][] and this project adheres to [Semanti * Added changelog * Added experimental Nix flake * Added direnv configuration +* Added NixOS configuration example ### Changed @@ -90,9 +90,10 @@ make sudo make install ``` -Alternatively you can run (or install) the experimental Nix flake. +Alternatively you can run or install the experimental Nix flake: ```sh nix run git+https://git.skreutz.com/temp-postgres.git -- --help ``` +See the [NixOS example](./examples/nixos) for how to install `temp-postgres` on NixOS using Nix flakes. 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" ]; + } + ]; + }; + }; +} |