generated from stubbfel/nix-project-template
test
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Alpine",
|
"name": "Alpine",
|
||||||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
||||||
"image": "mcr.microsoft.com/devcontainers/base:alpine-3.17",
|
"image": "mcr.microsoft.com/devcontainers/base:alpine",
|
||||||
"features": {
|
"features": {
|
||||||
"ghcr.io/devcontainers/features/nix:1": {}
|
"ghcr.io/devcontainers/features/nix:1": {}
|
||||||
},
|
},
|
||||||
|
|||||||
4
alias.sh
Normal file
4
alias.sh
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/env sh
|
||||||
|
|
||||||
|
alias nixe='nix --experimental-features "nix-command flakes"'
|
||||||
|
alias ulock='nixe run .#devTasks.updateFlakeLock'
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
{
|
{
|
||||||
inputs.nixpkgs.url = "nixpkgs/nixos-23.05";
|
inputs.nixpkgs.url = "nixpkgs/nixos-23.05";
|
||||||
|
|
||||||
outputs = { self, nixpkgs }:
|
outputs = { self, nixpkgs }: rec {
|
||||||
let
|
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
|
||||||
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
||||||
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
};
|
||||||
in rec { nixpkgs = nixpkgsFor; };
|
|
||||||
}
|
}
|
||||||
|
|||||||
25
flake.lock
generated
25
flake.lock
generated
@@ -1,23 +1,38 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"config": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1,
|
||||||
|
"narHash": "sha256-x1tXOK1tiPQabKK5TOzHQ0HxtFobkEoxwWPvuo6YYvc=",
|
||||||
|
"path": "/nix/store/1cvr44p1k6r0qq7fydsp7x3yhpwgm0v9-source/config",
|
||||||
|
"type": "path"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"path": "/nix/store/1cvr44p1k6r0qq7fydsp7x3yhpwgm0v9-source/config",
|
||||||
|
"type": "path"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1668595291,
|
"lastModified": 1686331006,
|
||||||
"narHash": "sha256-j8cyfbtT5sAYPYwbERgTDzfD48ZernL0/V668eGpXAM=",
|
"narHash": "sha256-hElRDWUNG655aqF0awu+h5cmDN+I/dQcChRt2tGuGGU=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "6474d93e007e4d165bcf48e7f87de2175c93d10b",
|
"rev": "85bcb95aa83be667e562e781e9d186c57a07d757",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"id": "nixpkgs",
|
"id": "nixpkgs",
|
||||||
"ref": "nixos-22.05-small",
|
"ref": "nixos-23.05",
|
||||||
"type": "indirect"
|
"type": "indirect"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs"
|
"config": "config"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
102
flake.nix
102
flake.nix
@@ -1,76 +1,58 @@
|
|||||||
{
|
{
|
||||||
description = "";
|
description = "";
|
||||||
inputs.nixpkgs.url = "nixpkgs/nixos-22.05-small";
|
inputs = {
|
||||||
|
config.url = "./config";
|
||||||
outputs = { self, nixpkgs }:
|
playground.url = "./playground/example/service";
|
||||||
|
};
|
||||||
|
outputs = { self, config, playground }:
|
||||||
let
|
let
|
||||||
name = "develnixos.new";
|
|
||||||
version = "0.0.1";
|
version = "0.0.1";
|
||||||
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
|
name = "develnixos";
|
||||||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
|
||||||
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
forAllSystems = config.forAllSystems;
|
||||||
devTaskScripts = forAllSystems (system:
|
nixpkgsFor = config.nixpkgsFor;
|
||||||
{
|
devTaskScripts = forAllSystems (system: {
|
||||||
autoTag = nixpkgsFor.${system}.writeScript "auto_tag.sh" ''
|
autoTag = nixpkgsFor.${system}.writeScript "auto_tag.sh" ''
|
||||||
git tag --force v${version}
|
git tag --force v${version}
|
||||||
git push origin v${version}
|
git push origin v${version}
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
in
|
in rec {
|
||||||
rec {
|
packages = playground.packages;
|
||||||
packages = forAllSystems (system:
|
|
||||||
{
|
|
||||||
default = nixpkgsFor.${system}.stdenv.mkDerivation {
|
|
||||||
name = name;
|
|
||||||
src = self;
|
|
||||||
buildPhase = "echo nothing todo";
|
|
||||||
installPhase = "mkdir -p $out/bin; install -t $out/bin src/hello.sh";
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
apps = forAllSystems (system:
|
apps = forAllSystems (system:
|
||||||
let
|
let
|
||||||
updateLockScript = nixpkgsFor.${system}.writeShellScriptBin "update_flake_lock.sh" ''
|
updateLockScript =
|
||||||
nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs
|
nixpkgsFor.${system}.writeShellScriptBin "update_flake_lock.sh" ''
|
||||||
nix --experimental-features 'nix-command flakes' build
|
nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs
|
||||||
'';
|
nix --experimental-features 'nix-command flakes' build
|
||||||
in
|
|
||||||
{
|
|
||||||
default = { type = "app"; program = "${packages.${system}.default}/bin/hello.sh"; };
|
|
||||||
devTasks = {
|
|
||||||
updateFlakeLock = { type = "app"; program = "${updateLockScript}/bin/update_flake_lock.sh"; };
|
|
||||||
autoTag = { type = "app"; program = "${devTaskScripts.${system}.autoTag}"; };
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
devShells = forAllSystems (system:
|
|
||||||
{
|
|
||||||
default = nixpkgsFor.${system}.mkShell {
|
|
||||||
name = "dev-shell";
|
|
||||||
packages = [ ];
|
|
||||||
shellHook = ''
|
|
||||||
alias nixe="nix --experimental-features 'nix-command flakes'"
|
|
||||||
'';
|
'';
|
||||||
|
in {
|
||||||
|
default = {
|
||||||
|
type = "app";
|
||||||
|
program = "${packages.${system}.default}/bin/hello.sh";
|
||||||
|
};
|
||||||
|
devTasks = {
|
||||||
|
updateFlakeLock = {
|
||||||
|
type = "app";
|
||||||
|
program = "${updateLockScript}/bin/update_flake_lock.sh";
|
||||||
|
};
|
||||||
|
autoTag = {
|
||||||
|
type = "app";
|
||||||
|
program = "${devTaskScripts.${system}.autoTag}";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
hydraJobs = {
|
devShells = forAllSystems (system: {
|
||||||
tarball = nixpkgsFor.x86_64-linux.releaseTools.sourceTarball {
|
default = nixpkgsFor.${system}.mkShell {
|
||||||
name = name;
|
name = "dev-shell";
|
||||||
src = self;
|
packages = [ nixpkgsFor.${system}.nixfmt ];
|
||||||
version = version;
|
shellHook = ''
|
||||||
officialRelease = true;
|
. ./alias.sh
|
||||||
bootstrapBuildInputs = [ ];
|
|
||||||
distPhase = ''
|
|
||||||
mkdir $out/tarballs
|
|
||||||
tar -czvf $out/tarballs/${name}-${version}.tar.gz *
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
});
|
||||||
|
|
||||||
runCommandHook = {
|
|
||||||
recurseForDerivations = { };
|
|
||||||
autoTag = devTaskScripts.x86_64-linux.autoTag;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
5
playground/example/config/flake.nix
Normal file
5
playground/example/config/flake.nix
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
inputs = { config.url = "./config"; };
|
||||||
|
|
||||||
|
outputs = { self, config }: config;
|
||||||
|
}
|
||||||
62
playground/example/service/flake.nix
Normal file
62
playground/example/service/flake.nix
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
description = "";
|
||||||
|
inputs = { config.url = "./config"; };
|
||||||
|
outputs = { self, config }:
|
||||||
|
let
|
||||||
|
version = "0.0.1";
|
||||||
|
name = "develnixos";
|
||||||
|
|
||||||
|
forAllSystems = config.forAllSystems;
|
||||||
|
nixpkgsFor = config.nixpkgsFor;
|
||||||
|
devTaskScripts = forAllSystems (system: {
|
||||||
|
autoTag = nixpkgsFor.${system}.writeScript "auto_tag.sh" ''
|
||||||
|
git tag --force v${version}
|
||||||
|
git push origin v${version}
|
||||||
|
'';
|
||||||
|
});
|
||||||
|
in rec {
|
||||||
|
packages = forAllSystems (system: {
|
||||||
|
default = nixpkgsFor.${system}.stdenv.mkDerivation {
|
||||||
|
name = name;
|
||||||
|
src = self;
|
||||||
|
buildPhase = "echo nothing todo";
|
||||||
|
installPhase = "mkdir -p $out/bin; install -t $out/bin src/hello.sh";
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
apps = forAllSystems (system:
|
||||||
|
let
|
||||||
|
updateLockScript =
|
||||||
|
nixpkgsFor.${system}.writeShellScriptBin "update_flake_lock.sh" ''
|
||||||
|
nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs
|
||||||
|
nix --experimental-features 'nix-command flakes' build
|
||||||
|
'';
|
||||||
|
in {
|
||||||
|
default = {
|
||||||
|
type = "app";
|
||||||
|
program = "${packages.${system}.default}/bin/hello.sh";
|
||||||
|
};
|
||||||
|
devTasks = {
|
||||||
|
updateFlakeLock = {
|
||||||
|
type = "app";
|
||||||
|
program = "${updateLockScript}/bin/update_flake_lock.sh";
|
||||||
|
};
|
||||||
|
autoTag = {
|
||||||
|
type = "app";
|
||||||
|
program = "${devTaskScripts.${system}.autoTag}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
devShells = forAllSystems (system: {
|
||||||
|
default = nixpkgsFor.${system}.mkShell {
|
||||||
|
name = "dev-shell";
|
||||||
|
packages = [ nixpkgsFor.${system}.nixfmt ];
|
||||||
|
shellHook = ''
|
||||||
|
. ./alias.sh
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user