mirror of
https://github.com/daylinmorgan/oizys.git
synced 2025-02-22 15:15:50 -06:00
initial commit
This commit is contained in:
commit
82a55e6732
5 changed files with 116 additions and 0 deletions
45
README.md
Normal file
45
README.md
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
# nixos-flake-example
|
||||||
|
|
||||||
|
This shows how to build the same config, with and without flakes.
|
||||||
|
|
||||||
|
It also shows that `flake.nix` is basically just some syntax.
|
||||||
|
|
||||||
|
## overview
|
||||||
|
|
||||||
|
Note that these produce the same output:
|
||||||
|
|
||||||
|
1. with flakes:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
nix build '.#nixosConfigurations.mysystem.config.system.build.toplevel'
|
||||||
|
readlink -f result
|
||||||
|
/nix/store/0imi716z1qd04pfh4zdw6mb0gnxmakjs-nixos-system-nixos-21.03.20201020.007126e
|
||||||
|
|
||||||
|
nixos-rebuild build --flake '.#mysystem'
|
||||||
|
readlink -f result
|
||||||
|
/nix/store/0imi716z1qd04pfh4zdw6mb0gnxmakjs-nixos-system-nixos-21.03.20201020.007126e
|
||||||
|
```
|
||||||
|
|
||||||
|
Note, nixos-rebuild is basically just some magic to build the right derivation
|
||||||
|
and then set it as a system profile, and activate it.
|
||||||
|
|
||||||
|
2. without flakes:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
export NIX_PATH=nixos-config=$(pwd)/configuration.nix:nixpkgs=https://github.com/nixos/nixpkgs/archive/nixos-unstable.tar.gz
|
||||||
|
|
||||||
|
|
||||||
|
/nix/store/zidq625i13hvbbs8alkklj8k6a191xix-nixos-system-nixos-21.03pre-git
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note**, ~~same path~~ same inner system, just much slower due to no eval cache.
|
||||||
|
(they should be identical, but the flake version suffix is slightly different)
|
||||||
|
|
||||||
|
They build the same thing, the flake.nix just moves the redirection from the NixOS channel system
|
||||||
|
into the flake instead.
|
||||||
|
|
||||||
|
Note, if you come back and run this later, you may need to tell nix to update the `nixpkgs` that it
|
||||||
|
has pinned in `flake.lock` by running `nix flake update --update-input nixpkgs`. The non-flake example
|
||||||
|
is going to re-download the nixos-unstable build when the cache expires. This could cause any hash differences
|
||||||
|
if they're on different revs. (again, another reason to have control of it via flakes, and can lock it directly in the source.)
|
||||||
|
|
21
configuration.nix
Normal file
21
configuration.nix
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# Edit this configuration file to define what should be installed on
|
||||||
|
# your system. Help is available in the configuration.nix(5) man page
|
||||||
|
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
||||||
|
|
||||||
|
{ config, pkgs, lib, modulesPath, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
./hardware-configuration.nix
|
||||||
|
"${modulesPath}/installer/scan/not-detected.nix"
|
||||||
|
|
||||||
|
# list other modules here
|
||||||
|
];
|
||||||
|
|
||||||
|
services.sshd.enable = true;
|
||||||
|
|
||||||
|
# etc
|
||||||
|
|
||||||
|
}
|
||||||
|
|
27
flake.lock
generated
Normal file
27
flake.lock
generated
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1603153815,
|
||||||
|
"narHash": "sha256-uCav0CJ0Zm0vbqJiS9NUYD4XZg4Ww9bbsFzcDUzh2+U=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "007126eef72271480cb7670e19e501a1ad2c1ff2",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
17
flake.nix
Normal file
17
flake.nix
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
description = "An example NixOS configuration";
|
||||||
|
|
||||||
|
inputs.nixpkgs = { url = "github:nixos/nixpkgs/nixos-unstable"; };
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs }: {
|
||||||
|
nixosConfigurations = {
|
||||||
|
mysystem = nixpkgs.lib.nixosSystem {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
modules = [
|
||||||
|
(import ./configuration.nix)
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
6
hardware-configuration.nix
Normal file
6
hardware-configuration.nix
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
boot.loader.systemd-boot.enable = true; # (for UEFI systems only)
|
||||||
|
fileSystems."/".device = "/dev/disk/by-label/nixos";
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue