generated from stubbfel/nix-project-template
Initial commit
This commit is contained in:
6
.devcontainer/dev_shell/devcontainer-feature.json
Normal file
6
.devcontainer/dev_shell/devcontainer-feature.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"name": "DevShell",
|
||||||
|
"id": "dev_shell",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "A nix based dev shell"
|
||||||
|
}
|
||||||
4
.devcontainer/dev_shell/install.sh
Normal file
4
.devcontainer/dev_shell/install.sh
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/env sh
|
||||||
|
|
||||||
|
echo 'nix --experimental-features "nix-command flakes" develop' >/usr/bin/devShell
|
||||||
|
chmod +x /usr/bin/devShell
|
||||||
40
.devcontainer/devcontainer.json
Normal file
40
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"name": "Ubuntu",
|
||||||
|
"image": "mcr.microsoft.com/devcontainers/base:jammy",
|
||||||
|
// Features to add to the dev container. More info: https://containers.dev/implementors/features.
|
||||||
|
"features": {
|
||||||
|
"ghcr.io/devcontainers/features/docker-from-docker:1": {},
|
||||||
|
"ghcr.io/devcontainers/features/nix:1": {},
|
||||||
|
"./dev_shell": {}
|
||||||
|
},
|
||||||
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
|
// "forwardPorts": [],
|
||||||
|
// Use 'postCreateCommand' to run commands after the container is created.
|
||||||
|
"postCreateCommand": ".devcontainer/postCreateCommand.sh",
|
||||||
|
// Configure tool-specific properties.
|
||||||
|
"customizations": {
|
||||||
|
// Configure properties specific to VS Code.
|
||||||
|
"vscode": {
|
||||||
|
// Set *default* container specific settings.json values on container create.
|
||||||
|
"settings": {
|
||||||
|
"terminal.integrated.profiles.linux": {
|
||||||
|
"dev": {
|
||||||
|
"path": "/usr/bin/devShell",
|
||||||
|
"icon": "terminal-bash"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"terminal.integrated.defaultProfile.linux": "dev"
|
||||||
|
},
|
||||||
|
"extensions": [
|
||||||
|
"jnoortheen.nix-ide",
|
||||||
|
"ms-azuretools.vscode-docker",
|
||||||
|
"eamodio.gitlens",
|
||||||
|
"streetsidesoftware.code-spell-checker",
|
||||||
|
"timonwong.shellcheck",
|
||||||
|
"foxundermoon.shell-format"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||||
|
// "remoteUser": "root"
|
||||||
|
}
|
||||||
3
.devcontainer/postCreateCommand.sh
Executable file
3
.devcontainer/postCreateCommand.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/env sh
|
||||||
|
|
||||||
|
nix-env -i nixpkgs-fmt
|
||||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
result
|
||||||
9
LICENSE
Normal file
9
LICENSE
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022 stubbfel
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
26
README.md
Normal file
26
README.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# testtepmlate
|
||||||
|
|
||||||
|
## Nix Flake commands
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# nix flake are experimental and required following options --experimental-features 'nix-command flakes'
|
||||||
|
# create alias for nix --experimental-features 'nix-command flakes'
|
||||||
|
|
||||||
|
alias nixe && echo Alias for nixe exists || alias nixe="nix --experimental-features 'nix-command flakes'"
|
||||||
|
|
||||||
|
# build
|
||||||
|
nixe build
|
||||||
|
|
||||||
|
# run
|
||||||
|
nixe run
|
||||||
|
|
||||||
|
# open development shell
|
||||||
|
nixe develop
|
||||||
|
|
||||||
|
# update flake.lock
|
||||||
|
nixe run .#devTasks.updateFlakeLock
|
||||||
|
|
||||||
|
# tag project
|
||||||
|
nixe run .#devTasks.autoTag
|
||||||
|
|
||||||
|
```
|
||||||
26
flake.lock
generated
Normal file
26
flake.lock
generated
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1668595291,
|
||||||
|
"narHash": "sha256-j8cyfbtT5sAYPYwbERgTDzfD48ZernL0/V668eGpXAM=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "6474d93e007e4d165bcf48e7f87de2175c93d10b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"ref": "nixos-22.05-small",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
76
flake.nix
Normal file
76
flake.nix
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
{
|
||||||
|
description = "";
|
||||||
|
inputs.nixpkgs.url = "nixpkgs/nixos-22.05-small";
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs }:
|
||||||
|
let
|
||||||
|
name = "testtepmlate";
|
||||||
|
version = "0.0.1";
|
||||||
|
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
|
||||||
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||||
|
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
||||||
|
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 = [ ];
|
||||||
|
shellHook = ''
|
||||||
|
alias nixe="nix --experimental-features 'nix-command flakes'"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
hydraJobs = {
|
||||||
|
tarball = nixpkgsFor.x86_64-linux.releaseTools.sourceTarball {
|
||||||
|
name = name;
|
||||||
|
src = self;
|
||||||
|
version = version;
|
||||||
|
officialRelease = true;
|
||||||
|
bootstrapBuildInputs = [ ];
|
||||||
|
distPhase = ''
|
||||||
|
mkdir $out/tarballs
|
||||||
|
tar -czvf $out/tarballs/${name}-${version}.tar.gz *
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
runCommandHook = {
|
||||||
|
recurseForDerivations = { };
|
||||||
|
autoTag = devTaskScripts.x86_64-linux.autoTag;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
3
src/hello.sh
Executable file
3
src/hello.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/env bash
|
||||||
|
|
||||||
|
echo "hello world"
|
||||||
Reference in New Issue
Block a user