Initial commit

This commit is contained in:
2024-03-17 17:33:12 +01:00
commit c56d09816f
24 changed files with 564 additions and 0 deletions

101
flake-basic/README.md Normal file
View File

@ -0,0 +1,101 @@
# 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" ];
};
};
}
```

27
flake-basic/flake.lock generated Normal file
View File

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1710631334,
"narHash": "sha256-rL5LSYd85kplL5othxK5lmAtjyMOBg390sGBTb3LRMM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c75037bbf9093a2acb617804ee46320d6d1fea5a",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

19
flake-basic/flake.nix Normal file
View File

@ -0,0 +1,19 @@
{
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" ];
};
};
}