Skip to content

Commit

Permalink
Add dart template (#48)
Browse files Browse the repository at this point in the history
* broken: tried adding dart template

* broken: tried again

* fixed the problem

* added template to README

* restored lua formatting

* Delete template/dart/flake.lock

* Delete template/lua-app/flake.lock

* Delete template/ocaml/flake.lock

* added flake.lock

* read the template/dart/flake.nix

* github workflow for dart template

* workaround
  • Loading branch information
SecretVal authored Jan 29, 2024
1 parent ec43aeb commit c6cb4da
Show file tree
Hide file tree
Showing 14 changed files with 554 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/flake-language.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- python-app
- python-pkg
- rust
- dart
steps:
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
Expand All @@ -42,6 +43,7 @@ jobs:
- ocaml
- python-app
- rust
- dart
steps:
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
Expand Down
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,41 @@ rust-project.json


# End of https://www.toptal.com/developers/gitignore/api/macos,go,linux,ocaml,python,rust,rust-analyzer

# Created by https://www.toptal.com/developers/gitignore/api/dart
# Edit at https://www.toptal.com/developers/gitignore?templates=dart

### Dart ###
# See https://www.dartlang.org/guides/libraries/private-files

# Files and directories created by pub
.dart_tool/
.packages
build/
# If you're building an application, you may want to check-in your pubspec.lock
pubspec.lock

# Directory created by dartdoc
# If you don't generate documentation locally you can remove this line.
doc/api/

# dotenv environment variables file
.env*

# Avoid committing generated Javascript files:
*.dart.js
*.info.json # Produced by the --dump-info flag.
*.js # When generated by dart2js. Don't specify *.js if your
# project includes source files written in JavaScript.
*.js_
*.js.deps
*.js.map

.flutter-plugins
.flutter-plugins-dependencies

### Dart Patch ###
# dotenv environment variables file
.env

# End of https://www.toptal.com/developers/gitignore/api/dart
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Kickstart your Nix environments.
- [Python (application)](#python-application)
- [Python (package)](#python-package)
- [Rust](#rust)
- [Dart](#dart)
- Systems
- Linux
- [Home Manager](#home-manager)
Expand Down Expand Up @@ -383,6 +384,14 @@ Used for Rust applications.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#rust
```

#### Dart

Used for Dart applications.

```bash
nix flake init -t github:ALT-F4-LLC/kickstart.nix#dart
```

### Systems

#### Home Manager
Expand Down
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,17 @@
description = "Kickstart Node.js backend package flake.";
path = ./template/nodejs-backend;
};
dart = {
description = "Kickstart Dart package flake.";
path = ./template/dart;
};
};
};

perSystem = { config, self', inputs', pkgs, system, ... }: {
devShells = {
default = pkgs.mkShell {
buildInputs = with pkgs; [ just ];
buildInputs = with pkgs; [ just jq ];
};
};

Expand All @@ -106,6 +110,7 @@
example-python-app = lib.flake.python-app system;
example-python-pkg = lib.flake.python-pkg system;
example-rust = lib.flake.rust system;
example-dart = lib.flake.dart system;
};
};

Expand Down
13 changes: 13 additions & 0 deletions lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -236,5 +236,18 @@
cp --no-preserve=mode -r $src/* $out
cat $out/flake.nix
'';

dart = system:
let
pkgs = inputs.nixpkgs.legacyPackages.${system};
in
pkgs.runCommand "dart"
{
src = ../template/dart;
} ''
mkdir -p $out
cp --no-preserve=mode -r $src/* $out
cat $out/flake.nix
'';
};
}
1 change: 1 addition & 0 deletions template/dart/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
3 changes: 3 additions & 0 deletions template/dart/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
30 changes: 30 additions & 0 deletions template/dart/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.

include: package:lints/recommended.yaml

# Uncomment the following section to specify additional rules.

# linter:
# rules:
# - camel_case_types

# analyzer:
# exclude:
# - path/to/excluded/files/**

# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints

# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
5 changes: 5 additions & 0 deletions template/dart/bin/example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'package:example/example.dart' as example;

void main(List<String> arguments) {
print('Hello world: ${example.calculate()}!');
}
47 changes: 47 additions & 0 deletions template/dart/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
description = "Example kickstart Dart application project.";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
perSystem = { config, self', inputs', pkgs, system, lib, ... }:
let
inherit (pkgs) dockerTools buildDartApplication;
inherit (dockerTools) buildImage;
name = "example";
version = "0.1.0";
in
{
devShells = {
default = pkgs.mkShell {
inputsFrom = [ self'.packages.default ];
};
};

packages = {
default = buildDartApplication {
inherit version;
pname = name;
src = ./.;
autoPubspecLock = ./pubspec.lock;
dartEntryPoints = {
"bin/example" = "bin/example.dart";
};
};

docker = buildImage {
inherit name;
tag = version;
config = {
Cmd = "${self'.packages.default}/bin/${name}";
Env = [
"SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
];
};
};
};
};
};
}
3 changes: 3 additions & 0 deletions template/dart/lib/example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int calculate() {
return 6 * 7;
}
Loading

0 comments on commit c6cb4da

Please sign in to comment.