102 lines
1.8 KiB
Markdown
102 lines
1.8 KiB
Markdown
|
# flakes
|
||
|
|
||
|
Do not forget to `git add` the `flake.nix` file! Or you'll face the `does not exist` error.
|
||
|
|
||
|
```sh
|
||
|
> nix flake check
|
||
|
|
||
|
> nix build
|
||
|
|
||
|
> nix flake show
|
||
|
```
|
||
|
|
||
|
## Simplying
|
||
|
|
||
|
First step:
|
||
|
|
||
|
```nix
|
||
|
{
|
||
|
inputs = {
|
||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||
|
};
|
||
|
outputs = inputs: {
|
||
|
packages."x86_64-linux".default = derivation {
|
||
|
name = "simple";
|
||
|
builder = "${inputs.nixpkgs.legacyPackages."x86_64-linux".bash}/bin/bash";
|
||
|
args = [ "-c" "echo foo > $out" ];
|
||
|
src = ./.;
|
||
|
system = "x86_64-linux";
|
||
|
};
|
||
|
};
|
||
|
}
|
||
|
```
|
||
|
|
||
|
Second step:
|
||
|
|
||
|
```nix
|
||
|
{
|
||
|
inputs = {
|
||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||
|
};
|
||
|
outputs = { self, nixpkgs }: {
|
||
|
packages."x86_64-linux".default = derivation {
|
||
|
name = "simple";
|
||
|
builder = "${nixpkgs.legacyPackages."x86_64-linux".bash}/bin/bash";
|
||
|
args = [ "-c" "echo foo > $out" ];
|
||
|
src = ./.;
|
||
|
system = "x86_64-linux";
|
||
|
};
|
||
|
};
|
||
|
}
|
||
|
```
|
||
|
|
||
|
Third:
|
||
|
|
||
|
```nix
|
||
|
{
|
||
|
inputs = {
|
||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||
|
};
|
||
|
outputs = { self, nixpkgs }:
|
||
|
let
|
||
|
system = "x86_64-linux";
|
||
|
in
|
||
|
{
|
||
|
packages.${system}.default = derivation {
|
||
|
name = "simple";
|
||
|
builder = "${nixpkgs.legacyPackages.${system}.bash}/bin/bash";
|
||
|
args = [ "-c" "echo foo > $out" ];
|
||
|
src = ./.;
|
||
|
system = system;
|
||
|
};
|
||
|
};
|
||
|
}
|
||
|
```
|
||
|
|
||
|
Fourth:
|
||
|
|
||
|
```nix
|
||
|
{
|
||
|
inputs = {
|
||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||
|
};
|
||
|
outputs = { self, nixpkgs }:
|
||
|
let
|
||
|
name = "simple";
|
||
|
system = "x86_64-linux";
|
||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||
|
src = ./.;
|
||
|
in
|
||
|
{
|
||
|
packages.${system}.default = derivation {
|
||
|
inherit name src system;
|
||
|
builder = with pkgs; "${bash}/bin/bash";
|
||
|
args = [ "-c" "echo foo > $out" ];
|
||
|
};
|
||
|
};
|
||
|
}
|
||
|
```
|
||
|
|
||
|
|
||
|
|